Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Libraries/Network/RCTDataManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ - (void)executeQuery:(NSString *)queryType
} else {
encoding = NSUTF8StringEncoding;
}
int responseCode = (int)[((NSHTTPURLResponse *)response) statusCode];
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
NSDictionary *headerDict = [httpResponse allHeaderFields];
int responseCode = (int)[httpResponse statusCode];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be NSInteger, which is what the method actually returns . Not sure why we'd cast to an int (I appreciate that this was pre-existing, and not something you changed).

NSString *returnData = [[NSString alloc] initWithData:data encoding:encoding];
responseJSON = @{@"status": @(responseCode), @"responseText": returnData};
responseJSON = @{@"status": @(responseCode), @"responseHeaders": headerDict, @"responseText": returnData};
} else {
responseJSON = @{@"status": @0, @"responseText": [connectionError localizedDescription]};
}
Expand Down
11 changes: 8 additions & 3 deletions Libraries/Network/XMLHttpRequestBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ class XMLHttpRequestBase {
}

getAllResponseHeaders(): ?string {
/* Stub */
if (this.responseHeaders) {
var headers = [];
for (var headerName in this.responseHeaders) {
headers.push(headerName + ': ' + this.responseHeaders[headerName]);
}
return headers.join('\n');
}
return '';
}

getResponseHeader(header: string): ?string {
/* Stub */
return '';
return this.responseHeaders[header];
}

setRequestHeader(header: string, value: any): void {
Expand Down