annotate OrthancServer/Sources/OrthancHttpHandler.h @ 5633:5db4ed395d81

merge
author Alain Mazy <am@orthanc.team>
date Tue, 21 May 2024 12:28:21 +0200
parents 48b8dae6dc77
children f7adfb22e20e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
25 #include "../../OrthancFramework/Sources/HttpServer/IHttpHandler.h"
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace Orthanc
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 class OrthancHttpHandler : public IHttpHandler
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 private:
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 typedef std::list<IHttpHandler*> Handlers;
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 Handlers handlers_;
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 IHttpHandler *orthancRestApi_;
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 OrthancHttpHandler() : orthancRestApi_(NULL)
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
42 virtual bool CreateChunkedRequestReader(std::unique_ptr<IChunkedRequestReader>& target,
3414
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3401
diff changeset
43 RequestOrigin origin,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3401
diff changeset
44 const char* remoteIp,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3401
diff changeset
45 const char* username,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3401
diff changeset
46 HttpMethod method,
b9cba6a91780 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3401
diff changeset
47 const UriComponents& uri,
4335
82652c5fc04f cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
48 const HttpToolbox::Arguments& headers) ORTHANC_OVERRIDE;
3395
0ce9b4f5fdf5 new abstraction: IHttpHandler::CreateStreamHandler()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
49
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 virtual bool Handle(HttpOutput& output,
1571
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
51 RequestOrigin origin,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
52 const char* remoteIp,
3232f1c995a5 provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
53 const char* username,
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 HttpMethod method,
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 const UriComponents& uri,
4330
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
56 const HttpToolbox::Arguments& headers,
a01b1c9cbef4 moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
57 const HttpToolbox::GetArguments& getArguments,
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3395
diff changeset
58 const void* bodyData,
4335
82652c5fc04f cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4330
diff changeset
59 size_t bodySize) ORTHANC_OVERRIDE;
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
1443
895ab369d63c refactoring: OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1442
diff changeset
61 void Register(IHttpHandler& handler,
895ab369d63c refactoring: OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1442
diff changeset
62 bool isOrthancRestApi);
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 bool HasOrthancRestApi() const
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 return orthancRestApi_ != NULL;
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
1445
d26c8a93d05a refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1443
diff changeset
69 IHttpHandler& RestrictToOrthancRestApi(bool restrict);
1442
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 };
4ff8dd753d79 OrthancHttpHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }