Merge pull request #9855 from huangshiwu/v3_XmlHttpRequest

Fix XmlHttpRequestTest parsing error of response header on iOS platform
This commit is contained in:
Huabing.Xu 2015-01-08 10:28:34 +08:00
commit b5f8666caf
4 changed files with 18 additions and 2 deletions

View File

@ -43,6 +43,7 @@
@property (readonly) NSInteger getDataTime;
@property (readonly) NSInteger responseCode;
@property (readonly) NSString *statusString;
@property (strong) NSError *responseError;

View File

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

View File

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

View File

@ -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();