LibHTTP: Make HTTP method names more accessible
Previously you could only get the name of an HttpRequest::Method if you already had an HttpRequest.
This commit is contained in:
parent
84953c5020
commit
9b891a423b
Notes:
sideshowbarker
2024-07-17 06:02:29 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/9b891a423b Pull-request: https://github.com/SerenityOS/serenity/pull/15533 Reviewed-by: https://github.com/linusg
2 changed files with 18 additions and 11 deletions
|
@ -12,32 +12,37 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
String HttpRequest::method_name() const
|
||||
String to_string(HttpRequest::Method method)
|
||||
{
|
||||
switch (m_method) {
|
||||
case Method::GET:
|
||||
switch (method) {
|
||||
case HttpRequest::Method::GET:
|
||||
return "GET";
|
||||
case Method::HEAD:
|
||||
case HttpRequest::Method::HEAD:
|
||||
return "HEAD";
|
||||
case Method::POST:
|
||||
case HttpRequest::Method::POST:
|
||||
return "POST";
|
||||
case Method::DELETE:
|
||||
case HttpRequest::Method::DELETE:
|
||||
return "DELETE";
|
||||
case Method::PATCH:
|
||||
case HttpRequest::Method::PATCH:
|
||||
return "PATCH";
|
||||
case Method::OPTIONS:
|
||||
case HttpRequest::Method::OPTIONS:
|
||||
return "OPTIONS";
|
||||
case Method::TRACE:
|
||||
case HttpRequest::Method::TRACE:
|
||||
return "TRACE";
|
||||
case Method::CONNECT:
|
||||
case HttpRequest::Method::CONNECT:
|
||||
return "CONNECT";
|
||||
case Method::PUT:
|
||||
case HttpRequest::Method::PUT:
|
||||
return "PUT";
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
String HttpRequest::method_name() const
|
||||
{
|
||||
return to_string(m_method);
|
||||
}
|
||||
|
||||
ByteBuffer HttpRequest::to_raw_request() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
|
@ -73,4 +73,6 @@ private:
|
|||
ByteBuffer m_body;
|
||||
};
|
||||
|
||||
String to_string(HttpRequest::Method);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue