Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.5k
Generic method#145
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Generic method #145
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
594485c
"status complete" callback added to support Simple-Response handling …
1d9c1bf
"status complete" callback added to support Simple-Response handling …
e68c9ea
Merge remote-tracking branch 'tomika/master' into simple_response
emberian f1baae5
Add tests for @tomika's patch
emberian 143202e
Initial implementation of generic HTTP methods
emberian c3c2fb0
Fix indentation
emberian af1b701
Tweak test (red)
emberian d5cb13b
Try and fix up invalid uri matching
emberian 7d7852d
Add generic method test
emberian ff4d643
More proper HTTP_BOTH handling
emberian 6d5f231
Don't break on long generic method names
emberian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -237,6 +237,9 @@ enum state | ||
| , s_start_req_or_res | ||
| , s_res_or_resp_H | ||
| , s_res_or_resp_HT | ||
| , s_res_or_resp_HTT | ||
| , s_res_or_resp_HTTP | ||
| , s_start_res | ||
| , s_res_H | ||
| , s_res_HT | ||
| @@ -459,6 +462,8 @@ parse_url_char(enum state s, const char ch) | ||
| return s_req_schema_slash; | ||
| } | ||
| return s_dead; /* handles the case of an invalid URI (no path, no colon | ||
| to mark the schema) */ | ||
| break; | ||
| case s_req_schema_slash: | ||
| @@ -581,6 +586,7 @@ size_t http_parser_execute (http_parser *parser, | ||
| const char *header_value_mark = 0; | ||
| const char *url_mark = 0; | ||
| const char *body_mark = 0; | ||
| const char *method_mark = 0; | ||
| /* We're in an error state. Don't bother doing anything. */ | ||
| if (HTTP_PARSER_ERRNO(parser) != HPE_OK) { | ||
| @@ -676,21 +682,50 @@ size_t http_parser_execute (http_parser *parser, | ||
| case s_res_or_resp_H: | ||
| if (ch == 'T') { | ||
| parser->type = HTTP_RESPONSE; | ||
| parser->state = s_res_HT; | ||
| parser->state = s_res_or_resp_HT; | ||
| } else { | ||
| if (ch != 'E') { | ||
| SET_ERRNO(HPE_INVALID_CONSTANT); | ||
| goto error; | ||
| parser->type = HTTP_REQUEST; | ||
| if (ch == 'E') { | ||
| parser->method = HTTP_HEAD; | ||
| } else { | ||
| parser->method = HTTP_GENERIC; | ||
| } | ||
| parser->type = HTTP_REQUEST; | ||
| parser->method = HTTP_HEAD; | ||
| parser->index = 2; | ||
| parser->state = s_req_method; | ||
| } | ||
| break; | ||
| case s_res_or_resp_HT: | ||
| if (ch == 'T') { | ||
| parser->state = s_res_or_resp_HTT; | ||
| } else { | ||
| parser->type = HTTP_REQUEST; | ||
| parser->method = HTTP_GENERIC; | ||
| parser->state = s_req_method; | ||
| } | ||
| break; | ||
| case s_res_or_resp_HTT: | ||
| if (ch == 'P') { | ||
| parser->state = s_res_or_resp_HTTP; | ||
| } else { | ||
| parser->type = HTTP_REQUEST; | ||
| parser->method = HTTP_GENERIC; | ||
| parser->state = s_req_method; | ||
| } | ||
| break; | ||
| case s_res_or_resp_HTTP: | ||
| if (ch == '/') { | ||
| parser->state = s_res_first_http_major; | ||
| } else { | ||
| parser->type = HTTP_REQUEST; | ||
| parser->method = HTTP_GENERIC; | ||
| parser->state = s_req_method; | ||
| } | ||
| break; | ||
| case s_start_res: | ||
| { | ||
| parser->flags = 0; | ||
| @@ -866,6 +901,7 @@ size_t http_parser_execute (http_parser *parser, | ||
| case s_res_line_almost_done: | ||
| STRICT_CHECK(ch != LF); | ||
| parser->state = s_header_field_start; | ||
| CALLBACK_NOTIFY(status_complete); | ||
| break; | ||
| case s_start_req: | ||
| @@ -880,6 +916,7 @@ size_t http_parser_execute (http_parser *parser, | ||
| goto error; | ||
| } | ||
| MARK(method); | ||
| parser->method = (enum http_method) 0; | ||
| parser->index = 1; | ||
| switch (ch) { | ||
| @@ -899,8 +936,7 @@ size_t http_parser_execute (http_parser *parser, | ||
| case 'T': parser->method = HTTP_TRACE; break; | ||
| case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; | ||
| default: | ||
| SET_ERRNO(HPE_INVALID_METHOD); | ||
| goto error; | ||
| parser->method = HTTP_GENERIC; break; | ||
| } | ||
| parser->state = s_req_method; | ||
| @@ -917,8 +953,19 @@ size_t http_parser_execute (http_parser *parser, | ||
| goto error; | ||
| } | ||
| if (parser->method == HTTP_GENERIC) { | ||
| if (ch == ' ') { | ||
| CALLBACK_DATA(method); | ||
| parser->state = s_req_spaces_before_url; | ||
| } | ||
| break; | ||
| } | ||
| matcher = method_strings[parser->method]; | ||
| /* TODO: parse full method before deciding it isn't generic */ | ||
| if (ch == ' ' && matcher[parser->index] == '\0') { | ||
| CALLBACK_DATA(method); | ||
| parser->state = s_req_spaces_before_url; | ||
This comment was marked as off-topic.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| } else if (ch == matcher[parser->index]) { | ||
| ; /* nada */ | ||
| @@ -967,8 +1014,7 @@ size_t http_parser_execute (http_parser *parser, | ||
| } else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') { | ||
| parser->method = HTTP_PROPPATCH; | ||
| } else { | ||
| SET_ERRNO(HPE_INVALID_METHOD); | ||
| goto error; | ||
| parser->method = HTTP_GENERIC; | ||
| } | ||
| ++parser->index; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.