Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ size_t http_parser_execute (http_parser *parser,
uint64_t index = parser->index;
uint64_t nread = parser->nread;

/* technically we could combine all of these (except for url_mark) into one
variable, saving stack space, but it seems more clear to have them
separated. */
const char *header_field_mark = 0;
const char *header_value_mark = 0;
const char *url_mark = 0;

/* We're in an error state. Don't bother doing anything. */
if (HTTP_PARSER_ERRNO(parser) != HPE_OK) {
return 0;
Expand All @@ -396,13 +403,6 @@ size_t http_parser_execute (http_parser *parser,
}
}

/* technically we could combine all of these (except for url_mark) into one
variable, saving stack space, but it seems more clear to have them
separated. */
const char *header_field_mark = 0;
const char *header_value_mark = 0;
const char *url_mark = 0;

if (state == s_header_field)
header_field_mark = data;
if (state == s_header_value)
Expand Down Expand Up @@ -690,12 +690,14 @@ size_t http_parser_execute (http_parser *parser,

case s_req_method:
{
const char *matcher;

if (ch == '\0') {
SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}

const char *matcher = method_strings[parser->method];
matcher = method_strings[parser->method];
if (ch == ' ' && matcher[index] == '\0') {
state = s_req_spaces_before_url;
} else if (ch == matcher[index]) {
Expand Down
6 changes: 5 additions & 1 deletion http_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ extern "C" {
#define HTTP_PARSER_VERSION_MAJOR 1
#define HTTP_PARSER_VERSION_MINOR 0

#if RUBY_VERSION >= 190
#include <ruby/config.h>
#endif

#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(_MSC_VER)
#if !defined(HAVE_STDINT_H)
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
Expand Down