mirror of
https://github.com/RGBCube/serenity
synced 2025-07-13 16:37:34 +00:00

Now connect() will return immediately. Later on, when the socket is actually connected, it will call GSocket::on_connected from the event loop. :^)
33 lines
680 B
C++
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;
|
|
};
|