mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
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:
parent
ecc874ab7c
commit
2a7fa54019
3 changed files with 34 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-05-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSHTTPURLHandle.m:
|
||||
* Source/NSURLProtocol.m:
|
||||
When creating the 'Host' header, omit the port part if the scheme is
|
||||
http/https and the port is the normal 80/443. A workaround for buggy
|
||||
software which doesn't understand the spec saying that the port is
|
||||
'optional', not 'omitted' in these cases.
|
||||
|
||||
2014-05-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDebug.m:
|
||||
|
|
|
@ -407,6 +407,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
|
||||
if ((id)NSMapGet(wProperties, (void*)@"Host") == nil)
|
||||
{
|
||||
NSString *s = [u scheme];
|
||||
id p = [u port];
|
||||
id h = [u host];
|
||||
|
||||
|
@ -414,7 +415,16 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
{
|
||||
h = @""; // Must use 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)
|
||||
{
|
||||
NSMapInsert(wProperties, (void*)@"Host", (void*)h);
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue