]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/HTTPRequest.cxx
canvas::Layout: support for contents margins.
[simgear.git] / simgear / io / HTTPRequest.cxx
index 535ec402da8fa9c043ded3de7f9f7e0d0238fa63..0809c70a4194128f1ddbc9d7b3908835e264e712 100644 (file)
@@ -39,7 +39,7 @@ Request* Request::done(const Callback& cb)
   if( _ready_state == DONE )
     cb(this);
   else
-    _cb_done = cb;
+    _cb_done.push_back(cb);
 
   return this;
 }
@@ -50,7 +50,7 @@ Request* Request::fail(const Callback& cb)
   if( _ready_state == FAILED )
     cb(this);
   else
-    _cb_fail = cb;
+    _cb_fail.push_back(cb);
 
   return this;
 }
@@ -61,7 +61,7 @@ Request* Request::always(const Callback& cb)
   if( isComplete() )
     cb(this);
   else
-    _cb_always = cb;
+    _cb_always.push_back(cb);
 
   return this;
 }
@@ -304,7 +304,9 @@ void Request::setFailure(int code, const std::string& reason)
 {
   _responseStatus = code;
   _responseReason = reason;
-  setReadyState(FAILED);
+
+  if( !isComplete() )
+    setReadyState(FAILED);
 }
 
 //------------------------------------------------------------------------------
@@ -319,22 +321,19 @@ void Request::setReadyState(ReadyState state)
     onDone();
     onAlways();
 
-    if( _cb_done )
-      _cb_done(this);
+    _cb_done(this);
   }
   else if( state == FAILED )
   {
     onFail();
     onAlways();
 
-    if( _cb_fail )
-      _cb_fail(this);
+    _cb_fail(this);
   }
   else
     return;
 
-  if( _cb_always )
-    _cb_always(this);
+  _cb_always(this);
 }
 
 //------------------------------------------------------------------------------
@@ -346,9 +345,6 @@ void Request::abort()
 //----------------------------------------------------------------------------
 void Request::abort(const std::string& reason)
 {
-  if( isComplete() )
-    return;
-
   setFailure(-1, reason);
   _willClose = true;
 }