ladybird/LibCore/CHttpRequest.cpp
Robin Burchell 0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00

45 lines
838 B
C++

#include <AK/StringBuilder.h>
#include <LibCore/CHttpJob.h>
#include <LibCore/CHttpRequest.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();
}