Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
6a21a6f1
Commit
6a21a6f1
authored
Nov 22, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'alagoutte-http_parser'
parents
ecd143fc
661b99ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
26 deletions
+22
-26
third-party/http-parser/README.md
third-party/http-parser/README.md
+3
-3
third-party/http-parser/http_parser.c
third-party/http-parser/http_parser.c
+4
-14
third-party/http-parser/http_parser.h
third-party/http-parser/http_parser.h
+6
-2
third-party/http-parser/test.c
third-party/http-parser/test.c
+9
-7
No files found.
third-party/http-parser/README.md
View file @
6a21a6f1
...
...
@@ -75,7 +75,7 @@ if (parser->upgrade) {
HTTP needs to know where the end of the stream is. For example, sometimes
servers send responses without Content-Length and expect the client to
consume input (for the body) until EOF. To tell http_parser about EOF, give
`0`
as the forth parameter to
`http_parser_execute()`
. Callbacks and errors
`0`
as the fo
u
rth parameter to
`http_parser_execute()`
. Callbacks and errors
can still be encountered during an EOF, so one must still be prepared
to receive them.
...
...
@@ -110,7 +110,7 @@ followed by non-HTTP data.
information the Web Socket protocol.)
To support this, the parser will treat this as a normal HTTP message without a
body
. I
ssuing both on_headers_complete and on_message_complete callbacks. However
body
, i
ssuing both on_headers_complete and on_message_complete callbacks. However
http_parser_execute() will stop parsing at the end of the headers and return.
The user is expected to check if
`parser->upgrade`
has been set to 1 after
...
...
@@ -145,7 +145,7 @@ buffer to avoid copying memory around if this fits your application.
Reading headers may be a tricky task if you read/parse headers partially.
Basically, you need to remember whether last header callback was field or value
and apply following logic:
and apply
the
following logic:
(on_header_field and on_header_value shortened to on_h_*)
------------------------ ------------ --------------------------------------------
...
...
third-party/http-parser/http_parser.c
View file @
6a21a6f1
...
...
@@ -925,7 +925,7 @@ size_t http_parser_execute (http_parser *parser,
case
'G'
:
parser
->
method
=
HTTP_GET
;
break
;
case
'H'
:
parser
->
method
=
HTTP_HEAD
;
break
;
case
'L'
:
parser
->
method
=
HTTP_LOCK
;
break
;
case
'M'
:
parser
->
method
=
HTTP_MKCOL
;
/* or MOVE, MKACTIVITY, MERGE, M-SEARCH */
break
;
case
'M'
:
parser
->
method
=
HTTP_MKCOL
;
/* or MOVE, MKACTIVITY, MERGE, M-SEARCH
, MKCALENDAR
*/
break
;
case
'N'
:
parser
->
method
=
HTTP_NOTIFY
;
break
;
case
'O'
:
parser
->
method
=
HTTP_OPTIONS
;
break
;
case
'P'
:
parser
->
method
=
HTTP_POST
;
...
...
@@ -977,6 +977,8 @@ size_t http_parser_execute (http_parser *parser,
parser
->
method
=
HTTP_MSEARCH
;
}
else
if
(
parser
->
index
==
2
&&
ch
==
'A'
)
{
parser
->
method
=
HTTP_MKACTIVITY
;
}
else
if
(
parser
->
index
==
3
&&
ch
==
'A'
)
{
parser
->
method
=
HTTP_MKCALENDAR
;
}
else
{
SET_ERRNO
(
HPE_INVALID_METHOD
);
goto
error
;
...
...
@@ -1388,18 +1390,6 @@ size_t http_parser_execute (http_parser *parser,
break
;
}
if
(
ch
==
CR
)
{
parser
->
state
=
s_header_almost_done
;
CALLBACK_DATA
(
header_field
);
break
;
}
if
(
ch
==
LF
)
{
parser
->
state
=
s_header_field_start
;
CALLBACK_DATA
(
header_field
);
break
;
}
SET_ERRNO
(
HPE_INVALID_HEADER_TOKEN
);
goto
error
;
}
...
...
@@ -2142,7 +2132,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
u
->
port
=
u
->
field_set
=
0
;
s
=
is_connect
?
s_req_server_start
:
s_req_spaces_before_url
;
uf
=
old_uf
=
UF_MAX
;
old_uf
=
UF_MAX
;
for
(
p
=
buf
;
p
<
buf
+
buflen
;
p
++
)
{
s
=
parse_url_char
(
s
,
*
p
);
...
...
third-party/http-parser/http_parser.h
View file @
6a21a6f1
...
...
@@ -76,7 +76,7 @@ typedef struct http_parser_settings http_parser_settings;
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
* chunked' headers that indicate the presence of a body.
*
* http_data_cb does not return data chunks. It will be call
arbitraral
ly
* http_data_cb does not return data chunks. It will be call
ed arbitrari
ly
* many times for each string. E.G. you might get 10 callbacks for "on_url"
* each providing just a few characters more data.
*/
...
...
@@ -117,6 +117,8 @@ typedef int (*http_cb) (http_parser*);
/* RFC-5789 */
\
XX(24, PATCH, PATCH) \
XX(25, PURGE, PURGE) \
/* CalDAV */
\
XX(26, MKCALENDAR, MKCALENDAR) \
enum
http_method
{
...
...
@@ -278,13 +280,15 @@ struct http_parser_url {
* unsigned major = (version >> 16) & 255;
* unsigned minor = (version >> 8) & 255;
* unsigned patch = version & 255;
* printf("http_parser v%u.%u.%u\n", major, minor,
version
);
* printf("http_parser v%u.%u.%u\n", major, minor,
patch
);
*/
unsigned
long
http_parser_version
(
void
);
void
http_parser_init
(
http_parser
*
parser
,
enum
http_parser_type
type
);
/* Executes the parser. Returns number of parsed bytes. Sets
* `parser->http_errno` on error. */
size_t
http_parser_execute
(
http_parser
*
parser
,
const
http_parser_settings
*
settings
,
const
char
*
data
,
...
...
third-party/http-parser/test.c
View file @
6a21a6f1
...
...
@@ -2207,7 +2207,6 @@ print_error (const char *raw, size_t error_location)
break
;
case
'\n'
:
char_len
=
2
;
fprintf
(
stderr
,
"
\\
n
\n
"
);
if
(
this_line
)
goto
print
;
...
...
@@ -2910,15 +2909,11 @@ test_simple (const char *buf, enum http_errno err_expected)
{
parser_init
(
HTTP_REQUEST
);
size_t
parsed
;
int
pass
;
enum
http_errno
err
;
parsed
=
parse
(
buf
,
strlen
(
buf
));
pass
=
(
parsed
==
strlen
(
buf
));
parse
(
buf
,
strlen
(
buf
));
err
=
HTTP_PARSER_ERRNO
(
parser
);
parsed
=
parse
(
NULL
,
0
);
pass
&=
(
parsed
==
0
);
parse
(
NULL
,
0
);
parser_free
();
...
...
@@ -3476,6 +3471,13 @@ main (void)
test_simple
(
buf
,
HPE_INVALID_METHOD
);
}
// illegal header field name line folding
test_simple
(
"GET / HTTP/1.1
\r\n
"
"name
\r\n
"
" : value
\r\n
"
"
\r\n
"
,
HPE_INVALID_HEADER_TOKEN
);
const
char
*
dumbfuck2
=
"GET / HTTP/1.1
\r\n
"
"X-SSL-Bullshit: -----BEGIN CERTIFICATE-----
\r\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment