mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibHTTP+WebDriver+WebServer: Return error from HTTP request parser
This commit is contained in:
parent
5b31d1208f
commit
9220cdc285
6 changed files with 35 additions and 13 deletions
|
@ -18,6 +18,26 @@ namespace HTTP {
|
|||
|
||||
class HttpRequest {
|
||||
public:
|
||||
enum class ParseError {
|
||||
RequestTooLarge,
|
||||
OutOfMemory,
|
||||
UnsupportedMethod
|
||||
};
|
||||
|
||||
static StringView parse_error_to_string(ParseError error)
|
||||
{
|
||||
switch (error) {
|
||||
case ParseError::RequestTooLarge:
|
||||
return "Request too large"sv;
|
||||
case ParseError::OutOfMemory:
|
||||
return "Out of memory"sv;
|
||||
case ParseError::UnsupportedMethod:
|
||||
return "Unsupported method"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
enum Method {
|
||||
Invalid,
|
||||
HEAD,
|
||||
|
@ -61,7 +81,7 @@ public:
|
|||
|
||||
void set_headers(HashMap<DeprecatedString, DeprecatedString> const&);
|
||||
|
||||
static Optional<HttpRequest> from_raw_request(ReadonlyBytes);
|
||||
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
|
||||
static Optional<Header> get_http_basic_authentication_header(URL const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(DeprecatedString const&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue