comparison 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
comparison
equal deleted inserted replaced
1112:a119f9ae3640 1113:ba5c0908600c
31 31
32 32
33 #include "../PrecompiledHeaders.h" 33 #include "../PrecompiledHeaders.h"
34 #include "HttpFileSender.h" 34 #include "HttpFileSender.h"
35 35
36 #include "../OrthancException.h"
37
36 #include <boost/lexical_cast.hpp> 38 #include <boost/lexical_cast.hpp>
37 39
38 namespace Orthanc 40 namespace Orthanc
39 { 41 {
40 void HttpFileSender::SendHeader(HttpOutput& output) 42 void HttpFileSender::SendHeader(HttpOutput& output)
41 { 43 {
42 output.SendOkHeader(contentType_.c_str(), true, GetFileSize(), downloadFilename_.c_str()); 44 if (contentType_.size() > 0)
45 {
46 output.SetContentType(contentType_.c_str());
47 }
48
49 if (downloadFilename_.size() > 0)
50 {
51 output.SetContentFilename(downloadFilename_.c_str());
52 }
53
54 output.SetContentLength(GetFileSize());
43 } 55 }
44 56
45 void HttpFileSender::Send(HttpOutput& output) 57 void HttpFileSender::Send(HttpOutput& output)
46 { 58 {
47 SendHeader(output); 59 SendHeader(output);
48 60
49 if (!SendData(output)) 61 if (!SendData(output))
50 { 62 {
51 output.SendHeader(HttpStatus_500_InternalServerError); 63 throw OrthancException(ErrorCode_InternalError);
64 //output.SendHeader(HttpStatus_500_InternalServerError);
52 } 65 }
53 } 66 }
54 } 67 }