Fix crash on the XmlHttpRequestTest for Lua and parsing error of response headers for HttpURLConnection

This commit is contained in:
samuele3hu 2015-01-04 17:09:35 +08:00
parent 26a6502558
commit 832a87f5f0
2 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -184,14 +184,14 @@ public class Cocos2dxHttpURLConnection
return null;
}
String header = null;
String header = "";
for (Entry<String, List<String>> 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";
}
}