|
|
@ -14,7 +14,7 @@ dump_url (const char *url, const struct http_parser_url *u)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n",
|
|
|
|
printf("\tfield_data[%u]: off: %u, len: %u, part: %.*s\n",
|
|
|
|
i,
|
|
|
|
i,
|
|
|
|
u->field_data[i].off,
|
|
|
|
u->field_data[i].off,
|
|
|
|
u->field_data[i].len,
|
|
|
|
u->field_data[i].len,
|
|
|
@ -24,16 +24,18 @@ dump_url (const char *url, const struct http_parser_url *u)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
|
|
|
|
struct http_parser_url u;
|
|
|
|
|
|
|
|
int len, connect, result;
|
|
|
|
|
|
|
|
|
|
|
|
if (argc != 3) {
|
|
|
|
if (argc != 3) {
|
|
|
|
printf("Syntax : %s connect|get url\n", argv[0]);
|
|
|
|
printf("Syntax : %s connect|get url\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
struct http_parser_url u;
|
|
|
|
len = strlen(argv[2]);
|
|
|
|
int len = strlen(argv[2]);
|
|
|
|
connect = strcmp("connect", argv[1]) == 0 ? 1 : 0;
|
|
|
|
int connect = strcmp("connect", argv[1]) == 0 ? 1 : 0;
|
|
|
|
|
|
|
|
printf("Parsing %s, connect %d\n", argv[2], connect);
|
|
|
|
printf("Parsing %s, connect %d\n", argv[2], connect);
|
|
|
|
|
|
|
|
|
|
|
|
int result = http_parser_parse_url(argv[2], len, connect, &u);
|
|
|
|
result = http_parser_parse_url(argv[2], len, connect, &u);
|
|
|
|
if (result != 0) {
|
|
|
|
if (result != 0) {
|
|
|
|
printf("Parse error : %d\n", result);
|
|
|
|
printf("Parse error : %d\n", result);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|