summaryrefslogtreecommitdiff
path: root/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-08 02:24:34 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-08 02:24:34 +0200
commit7fcca0ce4b776637100f5dc1da8fda4e91668730 (patch)
treefcafae555570e771fcca78be2069861b39beb1c8 /LibGUI
parent37ae00a4dd20e095ca58cf00d666ed5ab373f004 (diff)
downloadserenity-7fcca0ce4b776637100f5dc1da8fda4e91668730.zip
GHttp: Rename GHttpNetworkJob => GHttpJob. And tidy up a little bit.
Diffstat (limited to 'LibGUI')
-rw-r--r--LibGUI/GHttpJob.cpp (renamed from LibGUI/GHttpNetworkJob.cpp)17
-rw-r--r--LibGUI/GHttpJob.h (renamed from LibGUI/GHttpNetworkJob.h)8
-rw-r--r--LibGUI/GHttpRequest.cpp4
-rw-r--r--LibGUI/Makefile2
4 files changed, 15 insertions, 16 deletions
diff --git a/LibGUI/GHttpNetworkJob.cpp b/LibGUI/GHttpJob.cpp
index e87bdbfa67..3c278f0971 100644
--- a/LibGUI/GHttpNetworkJob.cpp
+++ b/LibGUI/GHttpJob.cpp
@@ -1,19 +1,19 @@
-#include <LibGUI/GHttpNetworkJob.h>
+#include <LibGUI/GHttpJob.h>
#include <LibGUI/GHttpResponse.h>
#include <LibGUI/GTCPSocket.h>
#include <stdio.h>
#include <unistd.h>
-GHttpNetworkJob::GHttpNetworkJob(const GHttpRequest& request)
+GHttpJob::GHttpJob(const GHttpRequest& request)
: m_request(request)
{
}
-GHttpNetworkJob::~GHttpNetworkJob()
+GHttpJob::~GHttpJob()
{
}
-void GHttpNetworkJob::start()
+void GHttpJob::start()
{
ASSERT(!m_socket);
m_socket = new GTCPSocket(this);
@@ -35,7 +35,7 @@ void GHttpNetworkJob::start()
while (!m_socket->can_read_line())
usleep(1);
ASSERT(m_socket->can_read_line());
- auto line = m_socket->read_line(1024);
+ auto line = m_socket->read_line(PAGE_SIZE);
if (line.is_null()) {
printf("Expected HTTP status\n");
return deferred_invoke([this](auto&){ did_fail(GNetworkJob::Error::TransmissionFailed); });
@@ -57,7 +57,7 @@ void GHttpNetworkJob::start()
if (m_state == State::InHeaders) {
while (!m_socket->can_read_line())
usleep(1);
- auto line = m_socket->read_line(1024);
+ auto line = m_socket->read_line(PAGE_SIZE);
if (line.is_null()) {
printf("Expected HTTP header\n");
return did_fail(GNetworkJob::Error::ProtocolFailed);
@@ -83,7 +83,7 @@ void GHttpNetworkJob::start()
continue;
}
ASSERT(m_state == State::InBody);
- auto payload = m_socket->receive(100000);
+ auto payload = m_socket->receive(PAGE_SIZE);
if (!payload) {
if (m_socket->eof()) {
m_state = State::Finished;
@@ -95,8 +95,7 @@ void GHttpNetworkJob::start()
}
auto response = GHttpResponse::create(m_code, move(m_headers), ByteBuffer::copy(buffer.data(), buffer.size()));
- deferred_invoke([this, response] (GObject&) {
- printf("in the deferred invoke lambda\n");
+ deferred_invoke([this, response] (auto&) {
did_finish(move(response));
});
}
diff --git a/LibGUI/GHttpNetworkJob.h b/LibGUI/GHttpJob.h
index 8abf7dff49..35ea33f243 100644
--- a/LibGUI/GHttpNetworkJob.h
+++ b/LibGUI/GHttpJob.h
@@ -6,14 +6,14 @@
class GTCPSocket;
-class GHttpNetworkJob final : public GNetworkJob {
+class GHttpJob final : public GNetworkJob {
public:
- explicit GHttpNetworkJob(const GHttpRequest&);
- virtual ~GHttpNetworkJob() override;
+ explicit GHttpJob(const GHttpRequest&);
+ virtual ~GHttpJob() override;
virtual void start() override;
- virtual const char* class_name() const override { return "GHttpNetworkJob"; }
+ virtual const char* class_name() const override { return "GHttpJob"; }
private:
enum class State {
diff --git a/LibGUI/GHttpRequest.cpp b/LibGUI/GHttpRequest.cpp
index 96e867eb11..529e340be2 100644
--- a/LibGUI/GHttpRequest.cpp
+++ b/LibGUI/GHttpRequest.cpp
@@ -1,5 +1,5 @@
#include <LibGUI/GHttpRequest.h>
-#include <LibGUI/GHttpNetworkJob.h>
+#include <LibGUI/GHttpJob.h>
#include <LibGUI/GEventLoop.h>
#include <AK/StringBuilder.h>
@@ -13,7 +13,7 @@ GHttpRequest::~GHttpRequest()
GNetworkJob* GHttpRequest::schedule()
{
- auto* job = new GHttpNetworkJob(*this);
+ auto* job = new GHttpJob(*this);
job->start();
return job;
}
diff --git a/LibGUI/Makefile b/LibGUI/Makefile
index 627b06965a..4053ecf04f 100644
--- a/LibGUI/Makefile
+++ b/LibGUI/Makefile
@@ -62,7 +62,7 @@ LIBGUI_OBJS = \
GNetworkResponse.o \
GHttpRequest.o \
GHttpResponse.o \
- GHttpNetworkJob.o \
+ GHttpJob.o \
GWindow.o
OBJS = $(SHAREDGRAPHICS_OBJS) $(LIBGUI_OBJS)