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 » [Bug] Httprequest - consecutive requests contain parts of previous requests
[Bug] Httprequest - consecutive requests contain parts of previous requests [message #44574] Fri, 03 April 2015 15:24 Go to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Hi,

When I execute consecutive requests (e.g. multipart/post/multipart) they contain parts of previous requests.
Of course I can call Clear() between requests, but it closes connection as well.

Test code:
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_FILE | LOG_CERR | LOG_TIMESTAMP);

	HttpRequest hr("http://posttestserver.com/post.php");
	hr.Trace();
	hr.KeepAlive();
	
	hr.New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
	
	hr.New();
	hr.Post("field1", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat");
	RLOG(hr.Execute());

	hr.New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
}

[Updated on: Fri, 03 April 2015 15:27]

Report message to a moderator

Re: [Bug] Httprequest - consecutive requests contain parts of previous requests [message #44576 is a reply to message #44574] Sat, 04 April 2015 09:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14175
Registered: November 2005
Ultimate Member
Thanks for reporting, filed in RM, will fix ASAP.
Re: [Bug] Httprequest - consecutive requests contain parts of previous requests [message #44585 is a reply to message #44576] Tue, 07 April 2015 10:44 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Hi,

I've just found ClearPost() - it clears all multipart and postdata variables, but content header must be cleared separately.

Working example:
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_FILE | LOG_CERR | LOG_TIMESTAMP);

	HttpRequest hr("http://posttestserver.com/post.php");
	hr.Trace();
	hr.KeepAlive();
	
	hr.ContentType(Null).ClearPost().New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
	
	hr.ContentType(Null).ClearPost().New();
	hr.Post("field1", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat");
	RLOG(hr.Execute());

	hr.ContentType(Null).ClearPost().New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
}
Re: [Bug] Httprequest - consecutive requests contain parts of previous requests [message #44605 is a reply to message #44585] Fri, 17 April 2015 10:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14175
Registered: November 2005
Ultimate Member
Zbych wrote on Tue, 07 April 2015 10:44
Hi,

I've just found ClearPost() - it clears all multipart and postdata variables, but content header must be cleared separately.

Working example:
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_FILE | LOG_CERR | LOG_TIMESTAMP);

	HttpRequest hr("http://posttestserver.com/post.php");
	hr.Trace();
	hr.KeepAlive();
	
	hr.ContentType(Null).ClearPost().New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
	
	hr.ContentType(Null).ClearPost().New();
	hr.Post("field1", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat");
	RLOG(hr.Execute());

	hr.ContentType(Null).ClearPost().New();
	hr.Part("field1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
	hr.Part("field2", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
	RLOG(hr.Execute());
}


Well, it really looks like behaviour is consistent with New documentation ("it does not change any existing settings").

It makes some sense, as in certain situations you want to retry existing request...

Perhaps the right solution would be to add "NewRequest", that resets data and keeps connection?
Re: [Bug] Httprequest - consecutive requests contain parts of previous requests [message #44606 is a reply to message #44605] Fri, 17 April 2015 10:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14175
Registered: November 2005
Ultimate Member
Well, I like NewRequest solution, so it is now in trunk....
Re: [Bug] Httprequest - consecutive requests contain parts of previous requests [message #44611 is a reply to message #44606] Wed, 22 April 2015 08:24 Go to previous message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Thank you.
Previous Topic: HttpRequest, Content-ID header in Part method
Next Topic: How to just Post data ?
Goto Forum:
  


Current Time: Sat Dec 21 13:39:52 CET 2024

Total time taken to generate the page: 0.02002 seconds