Home » U++ Library support » U++ MT-multithreading and servers » HttpRequest [FEATURE]: Add byte range request-header field (patch included)
HttpRequest [FEATURE]: Add byte range request-header field (patch included) [message #46206] |
Sat, 26 March 2016 09:27 |
omari
Messages: 273 Registered: March 2010
|
Experienced Member |
|
|
useful to continue an interrupted download, or to get a file header only
for example, to continue an interrupted download :
HttpRequest r(url);
FileAppend fa(localFile);
fa << r.Range(fa.GetSize()).Execute();
the patch:
1- add a memeber variable :
2- initialize this memeber in HttpRequest::Init() :
3- in HttpRequest::StartRequest(), add the content of 'range' to 'data' after the line (<< "Host: " << host_port << "\r\n") :
data << "URL: " << url << "\r\n"
<< "Host: " << host_port << "\r\n"
<< range
<< "Connection: " << (keep_alive ? "keep-alive\r\n" : "close\r\n")
<<...
4- in HttpRequest::StartConnect() , add the content of 'range' to 'data' after the line (<< "Host: " << host_port << "\r\n")
data << "CONNECT " << host_port << " HTTP/1.1\r\n"
<< "Host: " << host_port << "\r\n"
<< range;
5- add HttpRequest::Range() methode :
HttpRequest& Range(const int64 from, const int64 to)
{
range << "Range: bytes=" << from << "-" << to << "\r\n";
return *this;
}
HttpRequest& Range(const int64 from)
{
range << "Range: bytes=" << from << "-" << "\r\n";
return *this;
}
regards
omari.
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 18:43:01 CEST 2024
Total time taken to generate the page: 0.03591 seconds
|