]> git.mxchange.org Git - simgear.git/commitdiff
Fail HTTP request with missing/illegal protocols.
authorJames Turner <zakalawe@mac.com>
Sun, 20 Oct 2013 22:20:49 +0000 (23:20 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 20 Oct 2013 22:20:49 +0000 (23:20 +0100)
Instead of throwing, run the failure handler for requests with
either a missing spec or something other than http:// (eg, https
or ftp)

simgear/io/HTTPClient.cxx

index 8b4b25941bded817096a6323cd02e8d5beba4ffe..b3dbbf4a750df9f4bd8f66b61b6315fee359c5c7 100644 (file)
@@ -667,9 +667,16 @@ void Client::update(int waitTimeout)
 
 void Client::makeRequest(const Request_ptr& r)
 {
-    if( r->url().find("://") == std::string::npos )
-      throw std::runtime_error("Unable to parse URL (missing scheme)");
+    if( r->url().find("://") == std::string::npos ) {
+        r->setFailure(EINVAL, "malformed URL");
+        return;
+    }
 
+    if( r->url().find("http://") != 0 ) {
+        r->setFailure(EINVAL, "only HTTP protocol is supported");
+        return;
+    }
+    
     string host = r->host();
     int port = r->port();
     if (!d->proxy.empty()) {