mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9855 from huangshiwu/v3_XmlHttpRequest
Fix XmlHttpRequestTest parsing error of response header on iOS platform
This commit is contained in:
commit
b5f8666caf
|
@ -43,6 +43,7 @@
|
|||
@property (readonly) NSInteger getDataTime;
|
||||
|
||||
@property (readonly) NSInteger responseCode;
|
||||
@property (readonly) NSString *statusString;
|
||||
|
||||
@property (strong) NSError *responseError;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
@synthesize responseData;
|
||||
@synthesize getDataTime;
|
||||
@synthesize responseCode;
|
||||
@synthesize statusString;
|
||||
@synthesize responseError;
|
||||
@synthesize conn;
|
||||
@synthesize finish;
|
||||
|
@ -73,7 +74,20 @@
|
|||
responseHeader = [[httpResponse allHeaderFields] copy];
|
||||
|
||||
responseCode = httpResponse.statusCode;
|
||||
if (responseCode != 200)
|
||||
statusString = [[NSHTTPURLResponse localizedStringForStatusCode:responseCode] copy];
|
||||
if(responseCode == 200)
|
||||
statusString = @"OK";
|
||||
|
||||
/*The individual values of the numeric status codes defined for HTTP/1.1
|
||||
| “200” ; OK
|
||||
| “201” ; Created
|
||||
| “202” ; Accepted
|
||||
| “203” ; Non-Authoritative Information
|
||||
| “204” ; No Content
|
||||
| “205” ; Reset Content
|
||||
| “206” ; Partial Content
|
||||
*/
|
||||
if (responseCode >= 200 && responseCode < 300)
|
||||
{// something went wrong, abort the whole thing
|
||||
|
||||
[connection cancel];
|
||||
|
|
|
@ -279,6 +279,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
|
|||
|
||||
//handle response header
|
||||
NSMutableString *header = [NSMutableString new];
|
||||
[header appendFormat:@"HTTP/1.1 %ld %@\n", httpAsynConn.responseCode, httpAsynConn.statusString];
|
||||
for (id key in httpAsynConn.responseHeader)
|
||||
{
|
||||
[header appendFormat:@"%@: %@\n", key, [httpAsynConn.responseHeader objectForKey:key]];
|
||||
|
|
|
@ -116,7 +116,7 @@ void LuaMinXmlHttpRequest::_gotHeader(string header)
|
|||
pch = strtok (NULL, " ");
|
||||
mystream << pch;
|
||||
|
||||
pch = strtok (NULL, " ");
|
||||
pch = strtok (NULL, "\n");
|
||||
mystream << " " << pch;
|
||||
|
||||
_statusText = mystream.str();
|
||||
|
|
Loading…
Reference in New Issue