mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 09:04:30 +00:00
LibCore: Move HTTP classes from LibGUI to LibCore.
This commit is contained in:
44
LibCore/CHttpRequest.cpp
Normal file
44
LibCore/CHttpRequest.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <LibCore/CHttpRequest.h>
|
||||
#include <LibCore/CHttpJob.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
CHttpRequest::CHttpRequest()
|
||||
{
|
||||
}
|
||||
|
||||
CHttpRequest::~CHttpRequest()
|
||||
{
|
||||
}
|
||||
|
||||
CNetworkJob* CHttpRequest::schedule()
|
||||
{
|
||||
auto* job = new CHttpJob(*this);
|
||||
job->start();
|
||||
return job;
|
||||
}
|
||||
|
||||
String CHttpRequest::method_name() const
|
||||
{
|
||||
switch (m_method) {
|
||||
case Method::GET:
|
||||
return "GET";
|
||||
case Method::HEAD:
|
||||
return "HEAD";
|
||||
case Method::POST:
|
||||
return "POST";
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
ByteBuffer CHttpRequest::to_raw_request() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(method_name());
|
||||
builder.append(' ');
|
||||
builder.append(m_path);
|
||||
builder.append(" HTTP/1.0\nHost: ");
|
||||
builder.append(m_hostname);
|
||||
builder.append("\n\n");
|
||||
return builder.to_byte_buffer();
|
||||
}
|
||||
Reference in New Issue
Block a user