diff --git a/cocos/network/HttpClient-ios.mm b/cocos/network/HttpClient-ios.mm index 5be5271ffc..9a63e5e265 100644 --- a/cocos/network/HttpClient-ios.mm +++ b/cocos/network/HttpClient-ios.mm @@ -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 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]; } }