diff --git a/cocos/network/HttpClient-ios.mm b/cocos/network/HttpClient-ios.mm index ea56d4af16..b187939a53 100644 --- a/cocos/network/HttpClient-ios.mm +++ b/cocos/network/HttpClient-ios.mm @@ -188,9 +188,13 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream } } - NSString* requestData = [NSString stringWithUTF8String:request->getRequestData()]; - NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding]; - [nsrequest setHTTPBody:postData]; + char* requestDataBuffer = request->getRequestData(); + if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer)) + { + NSString* requestData = [NSString stringWithUTF8String:requestDataBuffer]; + NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding]; + [nsrequest setHTTPBody:postData]; + } } //read cookie propertities from file and set cookie diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHttpURLConnection.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHttpURLConnection.java index 40dfa8aa69..53b25e6100 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHttpURLConnection.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHttpURLConnection.java @@ -184,14 +184,14 @@ public class Cocos2dxHttpURLConnection return null; } - String header = null; + String header = ""; for (Entry> entry: headers.entrySet()) { String key = entry.getKey(); if (null == key) { - header += listToString(entry.getValue(), ","); + header += listToString(entry.getValue(), ",") + "\n"; } else { - header += key + ":" + listToString(entry.getValue(), ","); + header += key + ":" + listToString(entry.getValue(), ",") + "\n"; } }