annotate OrthancFramework/Sources/HttpServer/HttpOutput.h @ 5639:b6a6179a2a69

TimezoneOffsetFromUTC is now ignored for C-Find matching
author Alain Mazy <am@orthanc.team>
date Fri, 24 May 2024 15:11:28 +0200
parents 48b8dae6dc77
children f7adfb22e20e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1882
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4 * Department, University Hospital of Liege, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5469
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5469
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 59
diff changeset
12 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2142
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
26 #include "../Enumerations.h"
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
27 #include "IHttpOutputStream.h"
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
28 #include "IHttpStreamAnswer.h"
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
29
330
78a8eaa5f30b cookies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 324
diff changeset
30 #include <list>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <string>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <stdint.h>
2142
5a8840920121 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
33 #include <map>
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
34 #include <vector>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
36 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
38 class ORTHANC_PUBLIC HttpOutput : public boost::noncopyable
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 private:
330
78a8eaa5f30b cookies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 324
diff changeset
41 typedef std::list< std::pair<std::string, std::string> > Header;
78a8eaa5f30b cookies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 324
diff changeset
42
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
43 class StateMachine : public boost::noncopyable
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
44 {
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
45 public:
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
46 enum State
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
47 {
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
48 State_WritingHeader,
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
49 State_WritingBody,
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
50 State_WritingMultipart,
4672
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
51 State_Done,
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
52 State_WritingStream
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
53 };
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
54
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
55 private:
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
56 IHttpOutputStream& stream_;
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
57 State state_;
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
58
5407
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
59 bool isContentCompressible_;
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
60 HttpStatus status_;
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
61 bool hasContentLength_;
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
62 uint64_t contentLength_;
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
63 uint64_t contentPosition_;
1115
da56a7916e8a Experimental "KeepAlive" configuration option to enable HTTP Keep-Alive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1113
diff changeset
64 bool keepAlive_;
5119
bdec57f3cbf2 New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
65 unsigned int keepAliveTimeout_;
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
66 std::list<std::string> headers_;
5469
514fd39f87a8 improved handling of X-Content-Type-Options
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5407
diff changeset
67 bool hasXContentTypeOptions_;
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
68
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
69 std::string multipartBoundary_;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
70 std::string multipartContentType_;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
71
4672
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
72 void StartStreamInternal(const std::string& contentType);
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
73
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
74 public:
1115
da56a7916e8a Experimental "KeepAlive" configuration option to enable HTTP Keep-Alive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1113
diff changeset
75 StateMachine(IHttpOutputStream& stream,
5119
bdec57f3cbf2 New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
76 bool isKeepAlive,
bdec57f3cbf2 New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
77 unsigned int keepAliveTimeout);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
78
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
79 ~StateMachine();
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
80
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
81 void SetHttpStatus(HttpStatus status);
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
82
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
83 void SetContentLength(uint64_t length);
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
84
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
85 void SetContentType(const char* contentType);
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
86
5407
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
87 void SetContentCompressible(bool isCompressible);
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
88
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
89 void SetContentFilename(const char* filename);
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
90
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
91 void SetCookie(const std::string& cookie,
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
92 const std::string& value);
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
93
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
94 void AddHeader(const std::string& header,
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
95 const std::string& value);
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
96
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
97 void ClearHeaders();
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
98
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
99 void SendBody(const void* buffer, size_t length);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
100
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
101 void StartMultipart(const std::string& subType,
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
102 const std::string& contentType);
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
103
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1645
diff changeset
104 void SendMultipartItem(const void* item,
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1645
diff changeset
105 size_t length,
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1645
diff changeset
106 const std::map<std::string, std::string>& headers);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
107
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
108 void CloseMultipart();
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
109
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1517
diff changeset
110 void CloseBody();
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1517
diff changeset
111
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
112 State GetState() const
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
113 {
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
114 return state_;
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
115 }
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
116
5407
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
117 bool IsContentCompressible() const;
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
118
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
119 void CheckHeadersCompatibilityWithMultipart() const;
4672
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
120
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
121 void StartStream(const std::string& contentType);
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
122
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
123 void SendStreamItem(const void* data,
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
124 size_t size);
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
125
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
126 void CloseStream();
910
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
127 };
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
128
28a52982196e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 908
diff changeset
129 StateMachine stateMachine_;
1517
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
130 bool isDeflateAllowed_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
131 bool isGzipAllowed_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
132
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
133 HttpCompression GetPreferredCompression(size_t bodySize) const;
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
134
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 public:
1115
da56a7916e8a Experimental "KeepAlive" configuration option to enable HTTP Keep-Alive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1113
diff changeset
136 HttpOutput(IHttpOutputStream& stream,
5119
bdec57f3cbf2 New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
137 bool isKeepAlive,
bdec57f3cbf2 New configuration KeepAliveTimeout with a default value of 1 second
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
138 unsigned int keepAliveTimeout);
1517
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
139
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
140 void SetDeflateAllowed(bool allowed);
1517
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
141
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
142 bool IsDeflateAllowed() const;
1517
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
143
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
144 void SetGzipAllowed(bool allowed);
1517
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
145
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
146 bool IsGzipAllowed() const;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
5407
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
148 bool IsContentCompressible() const
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
149 {
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
150 return stateMachine_.IsContentCompressible();
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
151 }
3206537cbb56 HttpCompression: now disabled by default + only compress known compressible content types
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
152
1567
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
153 void SendStatus(HttpStatus status,
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
154 const char* message,
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
155 size_t messageSize);
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
156
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
157 void SendStatus(HttpStatus status);
1567
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
158
9c5d93510414 If error while calling the REST API, the answer body contains an error description
jodogne
parents: 1521
diff changeset
159 void SendStatus(HttpStatus status,
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
160 const std::string& message);
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 217
diff changeset
161
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
162 void SetContentType(MimeType contentType);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
163
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
164 void SetContentType(const std::string& contentType);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
165
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
166 void SetContentFilename(const char* filename);
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
167
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
168 void SetCookie(const std::string& cookie,
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
169 const std::string& value);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1115
diff changeset
171 void AddHeader(const std::string& key,
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
172 const std::string& value);
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1115
diff changeset
173
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1519
diff changeset
174 void Answer(const void* buffer,
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1519
diff changeset
175 size_t length);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
176
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1519
diff changeset
177 void Answer(const std::string& str);
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
178
1521
3606278d305e refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1519
diff changeset
179 void AnswerEmpty();
1113
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
180
ba5c0908600c Refactoring of HttpOutput ("Content-Length" header is now always sent)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1042
diff changeset
181 void SendMethodNotAllowed(const std::string& allowed);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
217
1ac3aacd10a5 simplifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 207
diff changeset
183 void Redirect(const std::string& path);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
908
e078ea944089 refactoring HttpOutput
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
185 void SendUnauthorized(const std::string& realm);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
186
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
187 void StartMultipart(const std::string& subType,
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
188 const std::string& contentType);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
189
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
190 void SendMultipartItem(const void* item,
1882
5cf2bd0abfa2 OrthancPluginSendMultipartItem2 for DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1645
diff changeset
191 size_t size,
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
192 const std::map<std::string, std::string>& headers);
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
193
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
194 void CloseMultipart();
1430
ad94a3583b07 Plugins can send answers as multipart messages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
195
4298
db3932f9660d abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
196 bool IsWritingMultipart() const;
1519
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1517
diff changeset
197
8bd0d897763f refactoring: IHttpStreamAnswer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1517
diff changeset
198 void Answer(IHttpStreamAnswer& stream);
3528
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
199
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
200 /**
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
201 * This method is a replacement to the combination
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
202 * "StartMultipart()" + "SendMultipartItem()". It generates the
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
203 * same answer, but it gives a chance to compress the body if
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
204 * "Accept-Encoding: gzip" is provided by the client, which is not
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
205 * possible in chunked transfers.
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
206 **/
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
207 void AnswerMultipartWithoutChunkedTransfer(
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
208 const std::string& subType,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
209 const std::string& contentType,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
210 const std::vector<const void*>& parts,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
211 const std::vector<size_t>& sizes,
f6fe095f7130 don't open a multipart stream if plugin only sends one part
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
212 const std::vector<const std::map<std::string, std::string>*>& headers);
4672
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
213
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
214 /**
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
215 * Contrarily to "Answer()", this method doesn't bufferizes the
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
216 * stream before sending it, which reduces memory but cannot be
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
217 * used to handle compression using "Content-Encoding".
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
218 **/
d9942d48fea7 ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
219 void AnswerWithoutBuffering(IHttpStreamAnswer& stream);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }