-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Use Boost.Beast to parse HTTP request (#6294)"
This reverts commit e7185b4.
- Loading branch information
1 parent
943bc94
commit e0cdaab
Showing
8 changed files
with
441 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "server/request_parser.hpp" | ||
#include "server/http/request.hpp" | ||
|
||
#include "util.hpp" | ||
|
||
#include <iterator> | ||
#include <string> | ||
|
||
using osrm::server::RequestParser; | ||
using osrm::server::http::request; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) | ||
{ | ||
std::string in(reinterpret_cast<const char *>(data), size); | ||
|
||
auto first = begin(in); | ||
auto last = end(in); | ||
|
||
RequestParser parser; | ||
request req; | ||
|
||
// &(*it) is needed to go from iterator to underlying item to pointer to underlying item | ||
parser.parse(req, &(*first), &(*last)); | ||
|
||
escape(&req); | ||
|
||
return 0; | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef REQUEST_PARSER_HPP | ||
#define REQUEST_PARSER_HPP | ||
|
||
#include "server/http/compression_type.hpp" | ||
#include "server/http/header.hpp" | ||
|
||
#include <tuple> | ||
|
||
namespace osrm | ||
{ | ||
namespace server | ||
{ | ||
|
||
namespace http | ||
{ | ||
struct request; | ||
} | ||
|
||
class RequestParser | ||
{ | ||
public: | ||
RequestParser(); | ||
|
||
enum class RequestStatus : char | ||
{ | ||
valid, | ||
invalid, | ||
indeterminate | ||
}; | ||
|
||
std::tuple<RequestStatus, http::compression_type> | ||
parse(http::request ¤t_request, char *begin, char *end); | ||
|
||
private: | ||
RequestStatus consume(http::request ¤t_request, const char input); | ||
|
||
bool is_char(const int character) const; | ||
|
||
bool is_CTL(const int character) const; | ||
|
||
bool is_special(const int character) const; | ||
|
||
bool is_digit(const int character) const; | ||
|
||
enum class internal_state : unsigned char | ||
{ | ||
method_start, | ||
method, | ||
uri_start, | ||
uri, | ||
http_version_h, | ||
http_version_t_1, | ||
http_version_t_2, | ||
http_version_p, | ||
http_version_slash, | ||
http_version_major_start, | ||
http_version_major, | ||
http_version_minor_start, | ||
http_version_minor, | ||
expecting_newline_1, | ||
header_line_start, | ||
header_lws, | ||
header_name, | ||
header_value, | ||
expecting_newline_2, | ||
expecting_newline_3 | ||
} state; | ||
|
||
http::header current_header; | ||
http::compression_type selected_compression; | ||
}; | ||
} // namespace server | ||
} // namespace osrm | ||
|
||
#endif // REQUEST_PARSER_HPP |
This file contains 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
Oops, something went wrong.