7 #include "cookiemanager.h"
8 #include "httpclientconnection.h"
74 return user_agent_header;
75 return peer.cmgr->httpHeaderLine(peer.hostname, uri) +
79 void setCookie(
const std::string &header_line,
const std::string &uri) {
81 peer.cmgr->setCookie(header_line, peer.hostname, uri);
83 virtual std::string cacheLabel() {
84 return peer.hostname + std::to_string(peer.port);
86 void setUserAgentString(
const std::string &s) {
87 if (s.find_first_of(
"\r\n") == std::string::npos)
88 user_agent_header =
"User-Agent: " + s +
"\r\n";
97 static const std::string &getLocalAddress() {
101 bool createNewConnection();
103 std::string proxyHost()
const {
104 return peer.proxyHost;
106 uint32_t proxyPort()
const {
107 return peer.proxyPort;
112 void setServer(
const std::string hostname, uint16_t port_number = 80) {
113 peer.hostname = hostname;
114 peer.port = port_number;
118 std::string user_agent_header;
119 std::string real_server;
120 static std::string local_address;
121 static struct addrinfo *local_ip;
Definition: cookiemanager.h:14
HTTP/1.1 client protocol.
Definition: httpclientconnection.h:39
API for HTTP clients.
Definition: httpclienttask.h:11
virtual bool requestComplete(HttpClientConnection *)=0
Called when response has been fully read.
virtual void payload(HttpClientConnection *, char *, size_t)
Data has arrived from the server.
Definition: httpclienttask.h:48
std::string serverHost() const
Return server's host name.
Definition: httpclienttask.h:61
static bool setLocalAddress(const std::string &addr, uint16_t iptype)
Bind all subsequent client sockets to the given local ip address.
Definition: httpclienttask.cpp:43
virtual bool headerComplete(HttpClientConnection *)
Called when response headers are fully read and parsed, except for websocket upgrades,...
Definition: httpclienttask.cpp:28
virtual bool websocketUpgrade(HttpClientConnection *)
Called after succesful websocket upgrade.
Definition: httpclienttask.cpp:36
virtual std::string httpHeaderLines(const std::string &uri) const
Extra header lines to be added to outgoing requests.
Definition: httpclienttask.h:72
virtual void newRequest(HttpClientConnection *)
Initiate next request, or ignore to close connection.
Definition: httpclienttask.h:16
virtual size_t doPost(HttpClientConnection *conn, size_t len)
Send POST data, return number of bytes sent.
Definition: httpclienttask.cpp:32
The host name and port number of a HTTP host.
Definition: httphost.h:17
Common API for HTTP server and client tasks.
Definition: httptask.h:12