Mercurial > hg > orthanc
annotate OrthancFramework/Sources/HttpServer/IHttpHandler.h @ 4602:cfdd1f59ff6f db-changes
fix OrthancCDatabasePlugin.h
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Mar 2021 19:25:27 +0100 |
parents | d9473bd5ed43 |
children | c8f444e8556d |
rev | line source |
---|---|
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * the License, or (at your option) any later version. |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * Lesser General Public License for more details. |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
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
|
17 * 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
|
18 * 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
|
19 * <http://www.gnu.org/licenses/>. |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
25 #if ORTHANC_SANDBOXED == 1 |
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
26 # error This file cannot be used in sandboxed environments |
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
27 #endif |
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
28 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
29 #include "../Compatibility.h" |
2142 | 30 #include "../Toolbox.h" |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include "HttpOutput.h" |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
32 #include "HttpToolbox.h" |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include <map> |
1515
c94353fbd4e9
cont http compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1446
diff
changeset
|
35 #include <set> |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include <vector> |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include <string> |
3414 | 38 #include <memory> |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 namespace Orthanc |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 class IHttpHandler : public boost::noncopyable |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 public: |
3414 | 45 class IChunkedRequestReader : public boost::noncopyable |
3395
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
46 { |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
47 public: |
3414 | 48 virtual ~IChunkedRequestReader() |
3395
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
49 { |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
50 } |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
51 |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
52 virtual void AddBodyChunk(const void* data, |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
53 size_t size) = 0; |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
54 |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
55 virtual void Execute(HttpOutput& output) = 0; |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
56 }; |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
57 |
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
58 |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 virtual ~IHttpHandler() |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 { |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 } |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
3414 | 63 /** |
3973
d86bddb50972
fix spelling errors according to debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
64 * This function allows one to deal with chunked transfers (new in |
3414 | 65 * Orthanc 1.5.7). It is only called if "method" is POST or PUT. |
66 **/ | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
67 virtual bool CreateChunkedRequestReader(std::unique_ptr<IChunkedRequestReader>& target, |
3414 | 68 RequestOrigin origin, |
69 const char* remoteIp, | |
70 const char* username, | |
71 HttpMethod method, | |
72 const UriComponents& uri, | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
73 const HttpToolbox::Arguments& headers) = 0; |
3395
0ce9b4f5fdf5
new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
74 |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 virtual bool Handle(HttpOutput& output, |
1571
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1517
diff
changeset
|
76 RequestOrigin origin, |
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1517
diff
changeset
|
77 const char* remoteIp, |
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1517
diff
changeset
|
78 const char* username, |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 HttpMethod method, |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 const UriComponents& uri, |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
81 const HttpToolbox::Arguments& headers, |
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
82 const HttpToolbox::GetArguments& getArguments, |
3401 | 83 const void* bodyData, |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1442
diff
changeset
|
84 size_t bodySize) = 0; |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
85 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
86 static bool SimpleGet(std::string& result, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
87 IHttpHandler& handler, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
88 RequestOrigin origin, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
89 const std::string& uri, |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
90 const HttpToolbox::Arguments& httpHeaders); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
91 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
92 static bool SimplePost(std::string& result, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
93 IHttpHandler& handler, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
94 RequestOrigin origin, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
95 const std::string& uri, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
96 const void* bodyData, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
97 size_t bodySize, |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
98 const HttpToolbox::Arguments& httpHeaders); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
99 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
100 static bool SimplePut(std::string& result, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
101 IHttpHandler& handler, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
102 RequestOrigin origin, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
103 const std::string& uri, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
104 const void* bodyData, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
105 size_t bodySize, |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
106 const HttpToolbox::Arguments& httpHeaders); |
4329
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
107 |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
108 static bool SimpleDelete(IHttpHandler& handler, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
109 RequestOrigin origin, |
9dc0e42f868b
moving static methods from HttpToolbox to IHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
110 const std::string& uri, |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4329
diff
changeset
|
111 const HttpToolbox::Arguments& httpHeaders); |
1441
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 }; |
f3672356c121
refactoring: IHttpHandler and HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 } |