Fix the Origin: header used in WebSocket requests.
Summary: RFC 6454 section 7 defines the Origin: header syntax, and it's a scheme, host, and optional port, not a URL. Section 6 defines serialization of the header, including omission of the port. Therefore, we need to omit the trailing slash in all cases, and omit the port if it matches the default port for the protocol. Closes https://github.com/facebook/react-native/pull/7920 Differential Revision: D3387619 fbshipit-source-id: 552756e63ad41463af357a5073fae56c96e58958
This commit is contained in:
parent
7028929d8f
commit
03512fb721
|
@ -1565,10 +1565,14 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
|
||||||
scheme = @"http";
|
scheme = @"http";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.port) {
|
int defaultPort = ([scheme isEqualToString:@"https"] ? 443 :
|
||||||
return [NSString stringWithFormat:@"%@://%@:%@/", scheme, self.host, self.port];
|
[scheme isEqualToString:@"http"] ? 80 :
|
||||||
|
-1);
|
||||||
|
int port = self.port.intValue;
|
||||||
|
if (port > 0 && port != defaultPort) {
|
||||||
|
return [NSString stringWithFormat:@"%@://%@:%d", scheme, self.host, port];
|
||||||
} else {
|
} else {
|
||||||
return [NSString stringWithFormat:@"%@://%@/", scheme, self.host];
|
return [NSString stringWithFormat:@"%@://%@", scheme, self.host];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue