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 |
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 #44585 is a reply to message #44576] |
Tue, 07 April 2015 10:44 |
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 |
|
mirek
Messages: 14175 Registered: November 2005
|
Ultimate Member |
|
|
Zbych wrote on Tue, 07 April 2015 10:44Hi,
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?
|
|
|
|
|
Goto Forum:
Current Time: Sat Dec 21 13:39:52 CET 2024
Total time taken to generate the page: 0.02002 seconds
|