Fix the error that the binary data would be truncated

This commit is contained in:
samuele3hu 2015-01-31 14:31:24 +08:00
parent a1c8c615ac
commit e6d50d7086
1 changed files with 2 additions and 2 deletions

View File

@ -164,6 +164,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:HttpClient::getInstance()->getTimeoutForConnect()]; timeoutInterval:HttpClient::getInstance()->getTimeoutForConnect()];
//set request type //set request type
[nsrequest setHTTPMethod:requestType]; [nsrequest setHTTPMethod:requestType];
@ -190,8 +191,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
char* requestDataBuffer = request->getRequestData(); char* requestDataBuffer = request->getRequestData();
if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer)) if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer))
{ {
NSString* requestData = [NSString stringWithUTF8String:requestDataBuffer]; NSData *postData = [NSData dataWithBytes:requestDataBuffer length:request->getRequestDataSize()];
NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding];
[nsrequest setHTTPBody:postData]; [nsrequest setHTTPBody:postData];
} }
} }