blob: 3f07fecaa1fde7242532c03ceef7548b3a8ed94c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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();
}
|