1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-13 16:37:34 +00:00
serenity/LibGUI/GHttpJob.h
Andreas Kling 6d5a54690e LibGUI: Make GSocket connection asynchronous.
Now connect() will return immediately. Later on, when the socket is actually
connected, it will call GSocket::on_connected from the event loop. :^)
2019-04-08 04:56:11 +02:00

33 lines
680 B
C++

#pragma once
#include <LibGUI/GNetworkJob.h>
#include <LibGUI/GHttpRequest.h>
#include <AK/HashMap.h>
class GTCPSocket;
class GHttpJob final : public GNetworkJob {
public:
explicit GHttpJob(const GHttpRequest&);
virtual ~GHttpJob() override;
virtual void start() override;
virtual const char* class_name() const override { return "GHttpJob"; }
private:
void on_socket_connected();
enum class State {
InStatus,
InHeaders,
InBody,
Finished,
};
GHttpRequest m_request;
GTCPSocket* m_socket { nullptr };
State m_state { State::InStatus };
int m_code { -1 };
HashMap<String, String> m_headers;
};