[haiku-commits] haiku: hrev48722 - src/kits/network/libnetapi

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 26 Jan 2015 09:39:58 +0100 (CET)

hrev48722 adds 1 changeset to branch 'master'
old head: 7b2c59b9b848f467d2229dedf91ca19899b8ed13
new head: c861dfdb7e58022b877c94a6f4ff3144854a240b
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=c861dfdb7e58+%5E7b2c59b9b848

----------------------------------------------------------------------------

c861dfdb7e58: HttpRequest: fix HTTP to HTTPS redirects
  
  When redirected from http to https, we did not switch to SSL and port
  443 and kept using unencrypted http on port 80.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48722
Commit:      c861dfdb7e58022b877c94a6f4ff3144854a240b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c861dfdb7e58
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Mon Jan 26 08:38:15 2015 UTC

----------------------------------------------------------------------------

1 file changed, 15 insertions(+), 8 deletions(-)
src/kits/network/libnetapi/HttpRequest.cpp | 23 +++++++++++++++--------

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/HttpRequest.cpp 
b/src/kits/network/libnetapi/HttpRequest.cpp
index 3f2f64d..1da64c2 100644
--- a/src/kits/network/libnetapi/HttpRequest.cpp
+++ b/src/kits/network/libnetapi/HttpRequest.cpp
@@ -79,10 +79,7 @@ BHttpRequest::BHttpRequest(const BUrl& url, bool ssl, const 
char* protocolName,
        fOptFollowLocation(true)
 {
        _ResetOptions();
-       if (fSSL)
-               fSocket = new(std::nothrow) CheckedSecureSocket(this);
-       else
-               fSocket = new(std::nothrow) BSocket();
+       fSocket = NULL;
 }
 
 
@@ -105,10 +102,7 @@ BHttpRequest::BHttpRequest(const BHttpRequest& other)
 {
        _ResetOptions();
                // FIXME some options may be copied from other instead.
-       if (fSSL)
-               fSocket = new(std::nothrow) CheckedSecureSocket(this);
-       else
-               fSocket = new(std::nothrow) BSocket();
+       fSocket = NULL;
 }
 
 
@@ -406,6 +400,12 @@ BHttpRequest::_ProtocolLoop()
                                        if (--maxRedirs > 0) {
                                                newRequest = true;
 
+                                               // Redirections may need a 
switch from http to https.
+                                               if (fUrl.Protocol() == "https")
+                                                       fSSL = true;
+                                               else if (fUrl.Protocol() == 
"http")
+                                                       fSSL = false;
+
                                                
_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT,
                                                        "Following: %s\n",
                                                        
fUrl.UrlString().String());
@@ -472,6 +472,13 @@ BHttpRequest::_ProtocolLoop()
 status_t
 BHttpRequest::_MakeRequest()
 {
+       delete fSocket;
+
+       if (fSSL)
+               fSocket = new(std::nothrow) CheckedSecureSocket(this);
+       else
+               fSocket = new(std::nothrow) BSocket();
+
        if (fSocket == NULL)
                return B_NO_MEMORY;
 


Other related posts:

  • » [haiku-commits] haiku: hrev48722 - src/kits/network/libnetapi - pulkomandy