Mercurial > hg > orthanc
diff Core/HttpServer/HttpFileSender.cpp @ 1113:ba5c0908600c
Refactoring of HttpOutput ("Content-Length" header is now always sent)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 02 Sep 2014 15:51:20 +0200 |
parents | a811bdf8b8eb |
children | 6e7e5ed91c2d |
line wrap: on
line diff
--- a/Core/HttpServer/HttpFileSender.cpp Mon Sep 01 12:20:26 2014 +0200 +++ b/Core/HttpServer/HttpFileSender.cpp Tue Sep 02 15:51:20 2014 +0200 @@ -33,13 +33,25 @@ #include "../PrecompiledHeaders.h" #include "HttpFileSender.h" +#include "../OrthancException.h" + #include <boost/lexical_cast.hpp> namespace Orthanc { void HttpFileSender::SendHeader(HttpOutput& output) { - output.SendOkHeader(contentType_.c_str(), true, GetFileSize(), downloadFilename_.c_str()); + if (contentType_.size() > 0) + { + output.SetContentType(contentType_.c_str()); + } + + if (downloadFilename_.size() > 0) + { + output.SetContentFilename(downloadFilename_.c_str()); + } + + output.SetContentLength(GetFileSize()); } void HttpFileSender::Send(HttpOutput& output) @@ -48,7 +60,8 @@ if (!SendData(output)) { - output.SendHeader(HttpStatus_500_InternalServerError); + throw OrthancException(ErrorCode_InternalError); + //output.SendHeader(HttpStatus_500_InternalServerError); } } }