Author: rfm
Date: Tue May 20 10:14:19 2014
New Revision: 37895

URL: http://svn.gna.org/viewcvs/gnustep?rev=37895&view=rev
Log:
Workaround for buggy server-side software

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Source/GSHTTPURLHandle.m
    libs/base/trunk/Source/NSURLProtocol.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=37895&r1=37894&r2=37895&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Tue May 20 10:14:19 2014
@@ -1,3 +1,12 @@
+2014-05-20  Richard Frith-Macdonald <[email protected]>
+
+       * 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 <[email protected]>
 
        * Source/NSDebug.m:

Modified: libs/base/trunk/Source/GSHTTPURLHandle.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSHTTPURLHandle.m?rev=37895&r1=37894&r2=37895&view=diff
==============================================================================
--- libs/base/trunk/Source/GSHTTPURLHandle.m    (original)
+++ libs/base/trunk/Source/GSHTTPURLHandle.m    Tue May 20 10:14:19 2014
@@ -407,6 +407,7 @@
 
   if ((id)NSMapGet(wProperties, (void*)@"Host") == nil)
     {
+      NSString  *s = [u scheme];
       id       p = [u port];
       id       h = [u host];
 
@@ -414,7 +415,16 @@
        {
          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);
        }

Modified: libs/base/trunk/Source/NSURLProtocol.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSURLProtocol.m?rev=37895&r1=37894&r2=37895&view=diff
==============================================================================
--- libs/base/trunk/Source/NSURLProtocol.m      (original)
+++ libs/base/trunk/Source/NSURLProtocol.m      Tue May 20 10:14:19 2014
@@ -1454,14 +1454,25 @@
                }
              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];
                    }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to