# HG changeset patch # User Sebastien Jodogne # Date 1403263853 -7200 # Node ID ef71057d8b269fb4497b2adee7808b1b57c78924 # Parent e078ea944089294a6b0bfb71adf55060f85c29fc refactoring diff -r e078ea944089 -r ef71057d8b26 Core/HttpServer/HttpOutputStream.cpp --- a/Core/HttpServer/HttpOutputStream.cpp Thu Jun 19 17:47:39 2014 +0200 +++ b/Core/HttpServer/HttpOutputStream.cpp Fri Jun 20 13:30:53 2014 +0200 @@ -53,7 +53,7 @@ " " + std::string(EnumerationToString(status)) + "\r\n"; - SendHeader(&s[0], s.size()); + Send(true, &s[0], s.size()); } void HttpOutputStream::SendHeaderData(const void* buffer, size_t length) @@ -63,7 +63,7 @@ throw OrthancException(ErrorCode_BadSequenceOfCalls); } - SendHeader(buffer, length); + Send(true, buffer, length); } void HttpOutputStream::SendHeaderString(const std::string& str) @@ -84,13 +84,13 @@ if (state_ == State_WritingHeader) { // Close the HTTP header before writing the body - SendHeader("\r\n", 2); + Send(true, "\r\n", 2); state_ = State_WritingBody; } if (length > 0) { - SendBody(buffer, length); + Send(false, buffer, length); } } diff -r e078ea944089 -r ef71057d8b26 Core/HttpServer/HttpOutputStream.h --- a/Core/HttpServer/HttpOutputStream.h Thu Jun 19 17:47:39 2014 +0200 +++ b/Core/HttpServer/HttpOutputStream.h Fri Jun 20 13:30:53 2014 +0200 @@ -57,9 +57,7 @@ { } - virtual void SendHeader(const void* buffer, size_t length) = 0; - - virtual void SendBody(const void* buffer, size_t length) = 0; + virtual void Send(bool isHeader, const void* buffer, size_t length) = 0; public: HttpOutputStream() : state_(State_WaitingHttpStatus) diff -r e078ea944089 -r ef71057d8b26 Core/HttpServer/MongooseServer.cpp --- a/Core/HttpServer/MongooseServer.cpp Thu Jun 19 17:47:39 2014 +0200 +++ b/Core/HttpServer/MongooseServer.cpp Fri Jun 20 13:30:53 2014 +0200 @@ -74,7 +74,7 @@ struct mg_connection* connection_; protected: - virtual void SendBody(const void* buffer, size_t length) + virtual void Send(bool isHeader, const void* buffer, size_t length) { if (length > 0) { @@ -82,11 +82,6 @@ } } - virtual void SendHeader(const void* buffer, size_t length) - { - SendBody(buffer, length); - } - public: MongooseOutputStream(struct mg_connection* connection) : connection_(connection) { diff -r e078ea944089 -r ef71057d8b26 Plugins/Engine/PluginsHttpHandler.cpp --- a/Plugins/Engine/PluginsHttpHandler.cpp Thu Jun 19 17:47:39 2014 +0200 +++ b/Plugins/Engine/PluginsHttpHandler.cpp Fri Jun 20 13:30:53 2014 +0200 @@ -56,12 +56,13 @@ return target_; } - virtual void SendHeaderData(const void* buffer, size_t length) + virtual void Send(bool isHeader, const void* buffer, size_t length) { - } + if (isHeader) + { + return; + } - virtual void SendBodyData(const void* buffer, size_t length) - { size_t pos = target_.size(); target_.resize(pos + length);