Fix Content-Type header checking of React/RCTJavascriptLoader.mm #15791
Summary: To fix this issue: https://github.com/facebook/react-native/issues/15791 Closes https://github.com/facebook/react-native/pull/15792 Differential Revision: D5813101 Pulled By: shergin fbshipit-source-id: fd3eb6f1d9ccdeb5373d1ba2b2df173ff7a8e986
This commit is contained in:
parent
11963d824d
commit
3ae45d5cb8
|
@ -284,16 +284,17 @@ static void attemptAsynchronousLoadOfBundleAtURL(NSURL *scriptURL, RCTSourceLoad
|
|||
|
||||
// Validate that the packager actually returned javascript.
|
||||
NSString *contentType = headers[@"Content-Type"];
|
||||
if (![contentType isEqualToString:@"application/javascript"] &&
|
||||
![contentType isEqualToString:@"text/javascript"]) {
|
||||
NSString *description = [NSString stringWithFormat:@"Expected Content-Type to be 'application/javascript' or 'text/javascript', but got '%@'.", contentType];
|
||||
NSString *mimeType = [[contentType componentsSeparatedByString:@";"] firstObject];
|
||||
if (![mimeType isEqualToString:@"application/javascript"] &&
|
||||
![mimeType isEqualToString:@"text/javascript"]) {
|
||||
NSString *description = [NSString stringWithFormat:@"Expected MIME-Type to be 'application/javascript' or 'text/javascript', but got '%@'.", mimeType];
|
||||
error = [NSError errorWithDomain:@"JSServer"
|
||||
code:NSURLErrorCannotParseResponse
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey: description,
|
||||
@"headers": headers,
|
||||
@"data": data
|
||||
}];
|
||||
}];
|
||||
onComplete(error, nil);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue