Mercurial > hg > orthanc
comparison Core/HttpServer/HttpOutput.h @ 0:3959d33612cc
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Jul 2012 14:32:22 +0200 |
parents | |
children | 3a584803783e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3959d33612cc |
---|---|
1 /** | |
2 * Palantir - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 **/ | |
19 | |
20 | |
21 #pragma once | |
22 | |
23 #include <string> | |
24 #include <stdint.h> | |
25 #include "../Enumerations.h" | |
26 #include "../FileStorage.h" | |
27 | |
28 namespace Palantir | |
29 { | |
30 class HttpOutput | |
31 { | |
32 private: | |
33 void SendHeaderInternal(HttpStatus status); | |
34 | |
35 void SendOkHeader(const char* contentType, | |
36 bool hasContentLength, | |
37 size_t contentLength); | |
38 | |
39 public: | |
40 virtual ~HttpOutput() | |
41 { | |
42 } | |
43 | |
44 virtual void Send(const void* buffer, size_t length) = 0; | |
45 | |
46 void SendString(const std::string& s); | |
47 | |
48 void SendOkHeader(); | |
49 | |
50 void SendOkHeader(uint64_t contentLength); | |
51 | |
52 void SendOkHeader(const std::string& contentType); | |
53 | |
54 void SendOkHeader(const std::string& contentType, | |
55 uint64_t contentLength); | |
56 | |
57 void SendMethodNotAllowedError(const std::string& allowed); | |
58 | |
59 void SendHeader(HttpStatus status); | |
60 | |
61 | |
62 // Higher-level constructs to send entire files or buffers ------------------- | |
63 | |
64 void AnswerBuffer(const std::string& buffer) | |
65 { | |
66 AnswerBufferWithContentType(buffer, ""); | |
67 } | |
68 | |
69 void AnswerBufferWithContentType(const std::string& buffer, | |
70 const std::string& contentType); | |
71 | |
72 void AnswerBufferWithContentType(const void* buffer, | |
73 size_t size, | |
74 const std::string& contentType); | |
75 | |
76 void AnswerFile(const std::string& path) | |
77 { | |
78 AnswerFileWithContentType(path, ""); | |
79 } | |
80 | |
81 void AnswerFileWithContentType(const std::string& path, | |
82 const std::string& contentType); | |
83 | |
84 void AnswerFileAutodetectContentType(const std::string& path); | |
85 | |
86 void AnswerFile(const FileStorage& storage, | |
87 const std::string& uuid) | |
88 { | |
89 AnswerFile(storage, uuid, ""); | |
90 } | |
91 | |
92 void AnswerFile(const FileStorage& storage, | |
93 const std::string& uuid, | |
94 const std::string& contentType); | |
95 | |
96 void Redirect(const std::string& path); | |
97 }; | |
98 } |