mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:57:35 +00:00
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
2 changed files with 18 additions and 11 deletions
|
@ -12,32 +12,37 @@
|
||||||
|
|
||||||
namespace HTTP {
|
namespace HTTP {
|
||||||
|
|
||||||
String HttpRequest::method_name() const
|
String to_string(HttpRequest::Method method)
|
||||||
{
|
{
|
||||||
switch (m_method) {
|
switch (method) {
|
||||||
case Method::GET:
|
case HttpRequest::Method::GET:
|
||||||
return "GET";
|
return "GET";
|
||||||
case Method::HEAD:
|
case HttpRequest::Method::HEAD:
|
||||||
return "HEAD";
|
return "HEAD";
|
||||||
case Method::POST:
|
case HttpRequest::Method::POST:
|
||||||
return "POST";
|
return "POST";
|
||||||
case Method::DELETE:
|
case HttpRequest::Method::DELETE:
|
||||||
return "DELETE";
|
return "DELETE";
|
||||||
case Method::PATCH:
|
case HttpRequest::Method::PATCH:
|
||||||
return "PATCH";
|
return "PATCH";
|
||||||
case Method::OPTIONS:
|
case HttpRequest::Method::OPTIONS:
|
||||||
return "OPTIONS";
|
return "OPTIONS";
|
||||||
case Method::TRACE:
|
case HttpRequest::Method::TRACE:
|
||||||
return "TRACE";
|
return "TRACE";
|
||||||
case Method::CONNECT:
|
case HttpRequest::Method::CONNECT:
|
||||||
return "CONNECT";
|
return "CONNECT";
|
||||||
case Method::PUT:
|
case HttpRequest::Method::PUT:
|
||||||
return "PUT";
|
return "PUT";
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String HttpRequest::method_name() const
|
||||||
|
{
|
||||||
|
return to_string(m_method);
|
||||||
|
}
|
||||||
|
|
||||||
ByteBuffer HttpRequest::to_raw_request() const
|
ByteBuffer HttpRequest::to_raw_request() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
|
@ -73,4 +73,6 @@ private:
|
||||||
ByteBuffer m_body;
|
ByteBuffer m_body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
String to_string(HttpRequest::Method);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue