-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (49 loc) · 1.27 KB
/
main.cpp
File metadata and controls
60 lines (49 loc) · 1.27 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "http11_parser.h"
#include <stdio.h>
static char http[] =
"GET /index.html HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"\r\n"
"Sdp goes here I guess";
static char rtsp_options[] =
"OPTIONS rtsp://example.com/media.mp4 RTSP/1.0\r\n"
"CSeq: 1\r\n"
"Require: implicit-play\r\n"
"Proxy-Require: gzipped-messages\r\n"
"\r\n";
void element_callback(
void *data,
const char *at,
size_t length)
{
printf("element!!! %.*s\n", (int)length, at);
}
void field_callback(
void *data,
const char *field,
size_t flen,
const char *value,
size_t vlen)
{
printf("field!!! %.*s %.*s\n", (int)flen, field, (int)vlen, value);
}
int main()
{
size_t nread;
http_parser parser;
parser.http_field = &field_callback;
parser.request_method = &element_callback;
parser.request_uri = &element_callback;
parser.fragment = &element_callback;
parser.request_path = &element_callback;
parser.query_string = &element_callback;
parser.http_version = &element_callback;
parser.header_done = &element_callback;
http_parser_init(&parser);
nread = http_parser_execute(
&parser,
rtsp_options,
sizeof(rtsp_options)-1,
0);
printf("nread: %lu\n", nread);
}