Store Range: header

This commit is contained in:
Kamil Trzcinski
2022-04-12 11:56:35 +02:00
parent 70b9a513ad
commit 6d0492e35a
3 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,9 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@ -13,8 +16,6 @@
#include "http/http.h"
#include "opts/log.h"
#define BUFSIZE 256
static int http_listen(int port, int maxcons)
{
struct sockaddr_in server = {0};
@ -58,6 +59,8 @@ static void http_process(http_worker_t *worker, FILE *stream)
return;
}
worker->range_header[0] = 0;
// Consume headers
for(int i = 0; i < 50; i++) {
char line[BUFSIZE];
@ -65,6 +68,10 @@ static void http_process(http_worker_t *worker, FILE *stream)
return;
if (line[0] == '\r' && line[1] == '\n')
break;
if (strcasestr(line, "Range:") == line) {
strcpy(worker->range_header, line);
}
}
worker->current_method = NULL;