Skip to content

Commit

Permalink
Fix Content-Type header checking of React/RCTJavascriptLoader.mm face…
Browse files Browse the repository at this point in the history
…book#15791

Summary:
To fix this issue: facebook#15791
Closes facebook#15792

Differential Revision: D5813101

Pulled By: shergin

fbshipit-source-id: fd3eb6f1d9ccdeb5373d1ba2b2df173ff7a8e986
  • Loading branch information
justinr1234 authored and facebook-github-bot committed Sep 20, 2017
1 parent 11963d8 commit 3ae45d5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions React/Base/RCTJavaScriptLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3ae45d5

Please sign in to comment.