Workaround for buggy server-side software

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37895 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2014-05-20 08:14:19 +00:00
parent ca7c8ec08b
commit e6dfab4119
3 changed files with 34 additions and 4 deletions

View file

@ -1454,14 +1454,25 @@ static NSURLProtocol *placeholder = nil;
}
if ([this->request valueForHTTPHeaderField: @"Host"] == nil)
{
id p = [u port];
id h = [u host];
NSString *s = [u scheme];
id p = [u port];
id h = [u host];
if (h == nil)
{
h = @""; // Must send an empty host header
}
if (p == nil)
if (([s isEqualToString: @"http"] && [p intValue] == 80)
|| ([s isEqualToString: @"https"] && [p intValue] == 443))
{
/* Some buggy systems object to the port being in
* the Host header when it's the default (optional)
* value.
* To keep them happy let's omit it in those cases.
*/
p = nil;
}
if (nil == p)
{
[m appendFormat: @"Host: %@\r\n", h];
}