2019-04-07 12:36:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-10 20:28:10 +00:00
|
|
|
#include <LibCore/CNetworkJob.h>
|
|
|
|
#include <LibCore/CHttpRequest.h>
|
2019-04-07 17:35:07 +00:00
|
|
|
#include <AK/HashMap.h>
|
2019-04-07 12:36:10 +00:00
|
|
|
|
2019-04-10 18:22:23 +00:00
|
|
|
class CTCPSocket;
|
2019-04-07 12:36:10 +00:00
|
|
|
|
2019-04-10 20:28:10 +00:00
|
|
|
class CHttpJob final : public CNetworkJob {
|
2019-04-07 12:36:10 +00:00
|
|
|
public:
|
2019-04-10 20:28:10 +00:00
|
|
|
explicit CHttpJob(const CHttpRequest&);
|
|
|
|
virtual ~CHttpJob() override;
|
2019-04-07 12:36:10 +00:00
|
|
|
|
|
|
|
virtual void start() override;
|
|
|
|
|
2019-04-10 20:28:10 +00:00
|
|
|
virtual const char* class_name() const override { return "CHttpJob"; }
|
2019-04-07 12:36:10 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-08 02:53:45 +00:00
|
|
|
void on_socket_connected();
|
|
|
|
|
2019-04-07 17:35:07 +00:00
|
|
|
enum class State {
|
|
|
|
InStatus,
|
|
|
|
InHeaders,
|
|
|
|
InBody,
|
|
|
|
Finished,
|
|
|
|
};
|
|
|
|
|
2019-04-10 20:28:10 +00:00
|
|
|
CHttpRequest m_request;
|
2019-04-10 18:22:23 +00:00
|
|
|
CTCPSocket* m_socket { nullptr };
|
2019-04-07 17:35:07 +00:00
|
|
|
State m_state { State::InStatus };
|
|
|
|
int m_code { -1 };
|
|
|
|
HashMap<String, String> m_headers;
|
2019-04-07 12:36:10 +00:00
|
|
|
};
|