eHttpStream: allow to set http headers without path in url
authormx3L <mx3ldev@gmail.com>
Sat, 5 Dec 2015 14:33:13 +0000 (15:33 +0100)
committermx3L <mx3ldev@gmail.com>
Sat, 5 Dec 2015 14:40:57 +0000 (15:40 +0100)
http headers string was trimmed when no path was in url

lib/base/httpstream.cpp

index d55d8c3..ed31d62 100644 (file)
@@ -42,6 +42,14 @@ int eHttpStream::openUrl(const std::string &url, std::string &newurl)
 
        close();
 
+       std::string extra_headers = "";
+       size_t pos = uri.find('#');
+       if (pos != std::string::npos)
+       {
+               extra_headers = uri.substr(pos + 1);
+               uri = uri.substr(0, pos);
+       }
+
        int pathindex = uri.find("/", 7);
        if (pathindex > 0)
        {
@@ -75,13 +83,6 @@ int eHttpStream::openUrl(const std::string &url, std::string &newurl)
                port = 80;
        }
 
-       std::string extra_headers = "";
-       size_t pos = uri.find('#');
-       if (pos != std::string::npos)
-       {
-               extra_headers = uri.substr(pos + 1);
-               uri = uri.substr(0, pos);
-       }
 
        streamSocket = Connect(hostname.c_str(), port, 10);
        if (streamSocket < 0)