Core: HttpRequest::KeepAlive (thanks Zbych!)

git-svn-id: svn://ultimatepp.org/upp/trunk@6488 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-10-24 17:33:11 +00:00
parent 32f4b323c2
commit 893e5cb16c
3 changed files with 10 additions and 1 deletions

View file

@ -43,6 +43,7 @@ void HttpRequest::Init()
force_digest = false;
std_headers = true;
hasurlvar = false;
keep_alive = false;
method = METHOD_GET;
phase = BEGIN;
redirect_count = 0;
@ -520,7 +521,7 @@ void HttpRequest::StartRequest()
if(std_headers) {
data << "URL: " << url << "\r\n"
<< "Host: " << host_port << "\r\n"
<< "Connection: close\r\n"
<< "Connection: " << (keep_alive ? "keep-alive\r\n" : "close\r\n")
<< "Accept: " << Nvl(accept, "*/*") << "\r\n"
<< "Accept-Encoding: gzip\r\n"
<< "User-Agent: " << Nvl(agent, "U++ HTTP request") << "\r\n";

View file

@ -340,6 +340,7 @@ class HttpRequest : public TcpSocket {
bool is_post;
bool std_headers;
bool hasurlvar;
bool keep_alive;
String contenttype;
String username;
String password;
@ -455,6 +456,7 @@ public:
HttpRequest& Accept(const String& a) { accept = a; return *this; }
HttpRequest& UserAgent(const String& a) { agent = a; return *this; }
HttpRequest& ContentType(const String& a) { contenttype = a; return *this; }
HttpRequest& KeepAlive(bool ka = true) { keep_alive = ka; return *this;}
HttpRequest& Proxy(const String& host, int port) { proxy_host = host; proxy_port = port; return *this; }
HttpRequest& Proxy(const char *p);

View file

@ -294,6 +294,12 @@ HTTP request`". Returns `*this.&]
]_[* ContentType]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 a])&]
[s2;%% Specifies `"Content`-Type`" HTTP request field. Returns `*this.&]
[s3;%% &]
[s4; &]
[s5;:HttpRequest`:`:KeepAlive`(bool`): [_^HttpRequest^ HttpRequest][@(0.0.255) `&]_[* KeepA
live]([@(0.0.255) bool]_[*@3 ka]_`=_[@(0.0.255) true])&]
[s2;%% If active, `"Connection`" HTTP request field is `"keep`-alive`",
otherwise `"close`". Returns `*this.&]
[s3;%% &]
[s4;%% &]
[s5;:HttpRequest`:`:Proxy`(const String`&`,int`): [_^HttpRequest^ HttpRequest][@(0.0.255) `&
]_[* Proxy]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 host],