2022-01-19 23:47:53 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class http_transfer : public acl::fiber
|
|
|
|
{
|
|
|
|
public:
|
2022-03-31 18:35:14 +08:00
|
|
|
http_transfer(acl::http_method_t method, request_t* req,
|
|
|
|
response_t* res, int port);
|
2022-01-19 23:47:53 +08:00
|
|
|
~http_transfer(void);
|
|
|
|
|
2022-01-24 18:36:08 +08:00
|
|
|
void wait(bool* keep_alive);
|
2022-01-19 23:47:53 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// @override
|
|
|
|
void run(void);
|
|
|
|
|
|
|
|
private:
|
2022-03-31 18:35:14 +08:00
|
|
|
acl::fiber_tbox<bool>* box_;
|
2022-01-24 18:36:08 +08:00
|
|
|
|
|
|
|
int port_;
|
|
|
|
acl::http_method_t method_;
|
2022-03-31 18:35:14 +08:00
|
|
|
request_t* req_;
|
|
|
|
response_t* res_;
|
2022-01-24 18:36:08 +08:00
|
|
|
acl::socket_stream conn_;
|
|
|
|
acl::http_client* client_;
|
|
|
|
|
2022-03-31 18:35:14 +08:00
|
|
|
acl::socket_stream req_in_;
|
|
|
|
acl::socket_stream res_out_;
|
|
|
|
acl::http_client* res_client_;
|
|
|
|
|
|
|
|
bool open_peer(request_t* req, acl::socket_stream* conn);
|
2022-01-24 18:36:08 +08:00
|
|
|
|
|
|
|
bool transfer_get(void);
|
|
|
|
bool transfer_post(void);
|
|
|
|
|
2022-03-31 18:35:14 +08:00
|
|
|
bool transfer_request_head(acl::socket_stream* conn);
|
|
|
|
bool transfer_request_body(acl::socket_stream* conn);
|
2022-01-24 18:36:08 +08:00
|
|
|
bool transfer_response(void);
|
2022-01-19 23:47:53 +08:00
|
|
|
};
|
|
|
|
|