diff Core/HttpServer/HttpOutput.cpp @ 911:306afd58a0b3 plugins

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 20 Jun 2014 13:45:22 +0200
parents 28a52982196e
children 8d1845feb277
line wrap: on
line diff
--- a/Core/HttpServer/HttpOutput.cpp	Fri Jun 20 13:38:19 2014 +0200
+++ b/Core/HttpServer/HttpOutput.cpp	Fri Jun 20 13:45:22 2014 +0200
@@ -42,38 +42,6 @@
 
 namespace Orthanc
 {
-  class HttpOutput::StateMachine : public boost::noncopyable
-  {
-  protected:
-    enum State
-    {
-      State_WaitingHttpStatus,
-      State_WritingHeader,      
-      State_WritingBody
-    };
-
-  private:
-    IHttpOutputStream& stream_;
-    State state_;
-
-  public:
-    HttpStateMachine() : 
-      state_(State_WaitingHttpStatus)
-    {
-    }
-
-    void SendHttpStatus(HttpStatus status);
-
-    void SendHeaderData(const void* buffer, size_t length);
-
-    void SendHeaderString(const std::string& str);
-
-    void SendBodyData(const void* buffer, size_t length);
-
-    void SendBodyString(const std::string& str);
-  };
-
-
   void HttpOutput::StateMachine::SendHttpStatus(HttpStatus status)
   {
     if (state_ != State_WaitingHttpStatus)
@@ -81,7 +49,7 @@
       throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
-    OnHttpStatusReceived(status);
+    stream_.OnHttpStatusReceived(status);
     state_ = State_WritingHeader;
 
     std::string s = "HTTP/1.1 " + 
@@ -89,7 +57,7 @@
       " " + std::string(EnumerationToString(status)) +
       "\r\n";
 
-    Send(true, &s[0], s.size());
+    stream_.Send(true, &s[0], s.size());
   }
 
   void HttpOutput::StateMachine::SendHeaderData(const void* buffer, size_t length)
@@ -99,7 +67,7 @@
       throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
-    Send(true, buffer, length);
+    stream_.Send(true, buffer, length);
   }
 
   void HttpOutput::StateMachine::SendHeaderString(const std::string& str)
@@ -120,13 +88,13 @@
     if (state_ == State_WritingHeader)
     {
       // Close the HTTP header before writing the body
-      Send(true, "\r\n", 2);
+      stream_.Send(true, "\r\n", 2);
       state_ = State_WritingBody;
     }
 
     if (length > 0)
     {
-      Send(false, buffer, length);
+      stream_.Send(false, buffer, length);
     }
   }
 
@@ -176,7 +144,7 @@
 
   void HttpOutput::SendOkHeader(const Header& header)
   {
-    stream_.SendHttpStatus(HttpStatus_200_Ok);
+    stateMachine_.SendHttpStatus(HttpStatus_200_Ok);
 
     std::string s;
     for (Header::const_iterator 
@@ -185,14 +153,14 @@
       s += it->first + ": " + it->second + "\r\n";
     }
 
-    stream_.SendHeaderString(s);
+    stateMachine_.SendHeaderString(s);
   }
 
 
   void HttpOutput::SendMethodNotAllowedError(const std::string& allowed)
   {
-    stream_.SendHttpStatus(HttpStatus_405_MethodNotAllowed);
-    stream_.SendHeaderString("Allow: " + allowed + "\r\n");
+    stateMachine_.SendHttpStatus(HttpStatus_405_MethodNotAllowed);
+    stateMachine_.SendHeaderString("Allow: " + allowed + "\r\n");
   }
 
 
@@ -206,7 +174,7 @@
       throw OrthancException("Please use the dedicated methods to this HTTP status code in HttpOutput");
     }
     
-    stream_.SendHttpStatus(status);
+    stateMachine_.SendHttpStatus(status);
   }
 
 
@@ -265,15 +233,15 @@
 
   void HttpOutput::Redirect(const std::string& path)
   {
-    stream_.SendHttpStatus(HttpStatus_301_MovedPermanently);
-    stream_.SendHeaderString("Location: " + path + "\r\n");
+    stateMachine_.SendHttpStatus(HttpStatus_301_MovedPermanently);
+    stateMachine_.SendHeaderString("Location: " + path + "\r\n");
   }
 
 
   void HttpOutput::SendUnauthorized(const std::string& realm)
   {
-    stream_.SendHttpStatus(HttpStatus_401_Unauthorized);
-    stream_.SendHeaderString("WWW-Authenticate: Basic realm=\"" + realm + "\"\r\n");
+    stateMachine_.SendHttpStatus(HttpStatus_401_Unauthorized);
+    stateMachine_.SendHeaderString("WWW-Authenticate: Basic realm=\"" + realm + "\"\r\n");
   }
 
 }