annotate Core/HttpServer/HttpStreamTranscoder.h @ 1796:5e08a5fe6b27 worklists

HierarchicalMatcher - extracting tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Nov 2015 18:32:00 +0100
parents 096a8af528c9
children b1291df2f780
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1525
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #pragma once
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "BufferHttpSender.h"
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include <memory> // For std::auto_ptr
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 namespace Orthanc
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 class HttpStreamTranscoder : public IHttpStreamAnswer
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 private:
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 IHttpStreamAnswer& source_;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 CompressionType sourceCompression_;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 uint64_t bytesToSkip_;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 uint64_t skipped_;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 uint64_t currentChunkOffset_;
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1525
diff changeset
49 bool ready_;
1525
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 std::auto_ptr<BufferHttpSender> uncompressed_;
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 void ReadSource(std::string& buffer);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1525
diff changeset
55 HttpCompression SetupZlibCompression(bool deflateAllowed);
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1525
diff changeset
56
1525
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 public:
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 HttpStreamTranscoder(IHttpStreamAnswer& source,
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 CompressionType compression) :
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 source_(source),
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 sourceCompression_(compression),
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 bytesToSkip_(0),
1526
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1525
diff changeset
63 skipped_(0),
096a8af528c9 fix streams, initialization/finalization of libcurl and openssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1525
diff changeset
64 ready_(false)
1525
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 // This is the first method to be called
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 virtual HttpCompression SetupHttpCompression(bool gzipAllowed,
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 bool deflateAllowed);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 virtual bool HasContentFilename(std::string& filename)
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 return source_.HasContentFilename(filename);
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 virtual std::string GetContentType()
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 return source_.GetContentType();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 virtual uint64_t GetContentLength();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 virtual bool ReadNextChunk();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 virtual const char* GetChunkContent();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 virtual size_t GetChunkSize();
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 };
f9b0169eb6bb testing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }