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 next message
omari is currently offline  omari
Messages: 265
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.
Re: HttpRequest [FEATURE]: Add byte range request-header field (patch included) [message #46207 is a reply to message #46206] Sat, 26 March 2016 10:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hi,

at first glance it looks quite specialized. Why do not just use

	HttpRequest&  Header(const char *id, const String& data);


r.Header("Range", String().Cat() << "bytes=" << from << "-" << to);




?

Mirek

[Updated on: Sat, 26 March 2016 10:10]

Report message to a moderator

Re: HttpRequest [FEATURE]: Add byte range request-header field (patch included) [message #46220 is a reply to message #46207] Mon, 28 March 2016 00:05 Go to previous message
omari is currently offline  omari
Messages: 265
Registered: March 2010
Experienced Member
Hi Mirek,

Your proposal is simpler, and it worked perfectly.

Upp continues to surprise me.

Thank you.


regards
omari.
Previous Topic: How to break the server loop ?
Next Topic: Multithread and INTERLOCK
Goto Forum:
  


Current Time: Thu Apr 25 21:08:06 CEST 2024

Total time taken to generate the page: 0.06370 seconds