get_header.c
813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdlib.h>
#include <string.h>
#include <search.h>
#include <ctype.h>
#include <stdio.h>
#include "class.h"
#include "interface/class.h"
#include "http/header.h"
#include "http/message.h"
#include "http/request/parser.h"
#include "ringbuffer.h"
ssize_t
httpRequestParserGetHeader(HttpRequestParser this, char * cr)
{
HttpMessage message = (HttpMessage)this->cur_request;
char * value;
char * name = this->buffer->buffer + this->buffer->bstart;
size_t len = cr - name;
value = memchr(
this->buffer->buffer + this->buffer->bstart,
':', len);
if (NULL == value) {
return -1;
}
*cr = 0;
*(value++) = 0;
while(' ' == *value) value++;
httpHeaderAdd(&(message->header), new(HttpHeader, name, value));
return 1; //* @TODO: return something useful here
}
// vim: set ts=4 sw=4: