Merge pull request #10315 from samuele3hu/v3_4_rc1

Fix the error that the binary data would be truncated
This commit is contained in:
Huabing.Xu 2015-02-01 07:18:31 +08:00
commit 173578cf41
1 changed files with 5 additions and 2 deletions

View File

@ -170,6 +170,10 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
//if request type is post or put,set header and data
if([requestType isEqual: @"POST"] || [requestType isEqual: @"PUT"])
{
if ([requestType isEqual: @"PUT"])
{
[nsrequest setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];
}
/* get custom header data (if set) */
std::vector<std::string> headers=request->getHeaders();
if(!headers.empty())
@ -190,8 +194,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
char* requestDataBuffer = request->getRequestData();
if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer))
{
NSString* requestData = [NSString stringWithUTF8String:requestDataBuffer];
NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding];
NSData *postData = [NSData dataWithBytes:requestDataBuffer length:request->getRequestDataSize()];
[nsrequest setHTTPBody:postData];
}
}