]> git.saurik.com Git - wxWidgets.git/commitdiff
include port number in HTTP Host header (closes #10632)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 25 Apr 2009 23:38:03 +0000 (23:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 25 Apr 2009 23:38:03 +0000 (23:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60364 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/http.cpp

index be39b122fa56ac46ee2e8ff9719410c4e83c0cb6..ad4c3ef8e9ba9755a17b53b6e4251bf65cb83ad4 100644 (file)
@@ -325,6 +325,10 @@ Major new features in this release
 
 All:
 
+- Include port number in host header in wxHTTP (Marcin 'Malcom' Malich).
+
+All (GUI):
+
 - wxHTML: add support for table borders width (Laurent Humbertclaude).
 
 i18n:
index f6a644fda7bd9cfe766d973f07210753048bec31..145ec61f3c8e2ae950ae924cf8524f5629162b60 100644 (file)
@@ -219,7 +219,10 @@ bool wxHTTP::Connect(const wxString& host, unsigned short port)
     else if (!addr->Service(wxT("http")))
         addr->Service(80);
 
-    SetHeader(wxT("Host"), host);
+    wxString hostHdr = host;
+    if ( port && port != 80 )
+        hostHdr << wxT(":") << port;
+    SetHeader(wxT("Host"), hostHdr);
 
     m_lastError = wxPROTO_NOERR;
     return true;
@@ -235,8 +238,14 @@ bool wxHTTP::Connect(const wxSockAddress& addr, bool WXUNUSED(wait))
     m_addr = addr.Clone();
 
     wxIPV4address *ipv4addr = wxDynamicCast(&addr, wxIPV4address);
-    if (ipv4addr)
-        SetHeader(wxT("Host"), ipv4addr->OrigHostname());
+    if ( ipv4addr )
+    {
+        wxString hostHdr = ipv4addr->OrigHostname();
+        unsigned short port = ipv4addr->Service();
+        if ( port && port != 80 )
+            hostHdr << wxT(":") << port;
+        SetHeader(wxT("Host"), hostHdr);
+    }
 
     m_lastError = wxPROTO_NOERR;
     return true;