Skip to content

Commit

Permalink
changes for HTTPClient to prevent thread object overwrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
U-ALAN-4083C32F28\Administrator authored and Alan DuBoff committed Oct 17, 2011
1 parent c0bf2d5 commit dcdb36b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
65 changes: 45 additions & 20 deletions modules/ti.Network/HTTPClient.cpp
Expand Up @@ -415,39 +415,64 @@ void HTTPClient::BeginWithPostDataObject(KObjectRef object)

bool HTTPClient::BeginRequest(KValueRef sendData)
{
int currentState = 0;

if (this->curlHandle)
throw ValueException::FromString("Tried to use an HTTPClient while "
"another transfer was in progress");

this->sendData = sendData;
this->sawHTTPStatus = false;
this->requestDataSent = 0;
this->requestDataWritten = 0;
this->responseDataReceived = 0;
this->responseCookies.clear();
this->aborted = false;
this->requestBytes = 0;
this->responseData.clear();
currentState = this->GetInt("readyState", 0);

this->SetInt("dataSent", 0);
this->SetInt("dataReceived", 0);
if (this->async && currentState <= 1) // ajd this should work, as Open() changes the readyState to 1
{ // and the readyState is set to 0 when CurlCleanup() is called
this->sendData = sendData;
this->sawHTTPStatus = false;
this->requestDataSent = 0;
this->requestDataWritten = 0;
this->responseDataReceived = 0;
this->responseCookies.clear();
this->aborted = false;
this->requestBytes = 0;
this->responseData.clear();

this->SetBool("timedOut", false);
this->SetNull("responseText");
this->SetNull("responseData");
this->SetNull("status");
this->SetNull("statusText");
this->SetInt("dataSent", 0);
this->SetInt("dataReceived", 0);

this->SetBool("timedOut", false);
this->SetNull("responseText");
this->SetNull("responseData");
this->SetNull("status");
this->SetNull("statusText");

if (this->async)
{
this->thread = new Poco::Thread();
this->thread->start(*this);
}
else
else if (currentState == 1)
{
this->sendData = sendData;
this->sawHTTPStatus = false;
this->requestDataSent = 0;
this->requestDataWritten = 0;
this->responseDataReceived = 0;
this->responseCookies.clear();
this->aborted = false;
this->requestBytes = 0;
this->responseData.clear();

this->SetInt("dataSent", 0);
this->SetInt("dataReceived", 0);

this->SetBool("timedOut", false);
this->SetNull("responseText");
this->SetNull("responseData");
this->SetNull("status");
this->SetNull("statusText");

this->ExecuteRequest();
} else
{
this->ExecuteRequest();
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/__init__.py
@@ -1,2 +1,2 @@
def get_titanium_version():
return '1.2.0'
return '1.2.0.RC4'

0 comments on commit dcdb36b

Please sign in to comment.