Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
omari is currently offline  omari
Messages: 266
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 :
	String range;


2- initialize this memeber in HttpRequest::Init() :
	range = "";


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.
 
Read Message
Read Message
Read Message
Previous Topic: How to break the server loop ?
Next Topic: Multithread and INTERLOCK
Goto Forum:
  


Current Time: Sun May 12 11:55:43 CEST 2024

Total time taken to generate the page: 0.02645 seconds