]> git.mxchange.org Git - simgear.git/commitdiff
HTTP: tweak for malformed header handling.
authorJames Turner <zakalawe@mac.com>
Tue, 7 Jan 2014 14:06:51 +0000 (14:06 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 7 Jan 2014 14:24:01 +0000 (14:24 +0000)
simgear/io/HTTPClient.cxx
simgear/io/HTTPRequest.cxx

index b7e19917bc315caefa7e43acbc293a0c7101f627..ecc63f844054154a5a99230658848f2d46da05fb 100644 (file)
@@ -65,6 +65,12 @@ class Connection;
 typedef std::multimap<std::string, Connection*> ConnectionDict;
 typedef std::list<Request_ptr> RequestList;
 
+static bool isFailureStatus(int httpStatus)
+{
+  int majorCode = httpStatus / 100;
+  return (majorCode != 2);
+}
+
 class Client::ClientPrivate
 {
 public:
@@ -214,8 +220,12 @@ public:
         assert(state == STATE_WAITING_FOR_RESPONSE);
         
         activeRequest = sentRequests.front();
-        
-      activeRequest->responseStart(buffer);
+       activeRequest->responseStart(buffer);
+       if (isFailureStatus(activeRequest->responseCode())) {
+         handleError(EIO);
+         return;
+       }
+      
       state = STATE_GETTING_HEADERS;
       buffer.clear();
       if (activeRequest->responseCode() == 204) {
index e3980ca10af3608209ca1e62b324374e0f47a28e..d51d97902ef3d47a61bb9a9f175bb546bd495b73 100644 (file)
@@ -115,7 +115,6 @@ void Request::responseStart(const std::string& r)
     const int maxSplit = 2; // HTTP/1.1 nnn reason-string
     string_list parts = strutils::split(r, NULL, maxSplit);
     if (parts.size() != 3) {
-        SG_LOG(SG_IO, SG_WARN, "HTTP::Request: malformed response start:" << r);
         setFailure(400, "malformed HTTP response header");
         return;
     }