Mercurial > hg > orthanc
comparison Core/HttpClient.h @ 476:4aae0261515e
move HttpClient
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Jul 2013 17:37:24 +0200 |
parents | OrthancCppClient/HttpClient.h@72cca077abf8 |
children | ff34c51cd3dd |
comparison
equal
deleted
inserted
replaced
475:72cca077abf8 | 476:4aae0261515e |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * Permission is hereby granted, free of charge, to any person | |
7 * obtaining a copy of this software and associated documentation | |
8 * files (the "Software"), to deal in the Software without | |
9 * restriction, including without limitation the rights to use, copy, | |
10 * modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 * of the Software, and to permit persons to whom the Software is | |
12 * furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be | |
15 * included in all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
24 * SOFTWARE. | |
25 **/ | |
26 | |
27 | |
28 #pragma once | |
29 | |
30 #include "../Core/Enumerations.h" | |
31 | |
32 #include <string> | |
33 #include <boost/shared_ptr.hpp> | |
34 #include <json/json.h> | |
35 | |
36 namespace Orthanc | |
37 { | |
38 class HttpClient | |
39 { | |
40 private: | |
41 struct PImpl; | |
42 boost::shared_ptr<PImpl> pimpl_; | |
43 | |
44 std::string url_; | |
45 std::string credentials_; | |
46 HttpMethod method_; | |
47 HttpStatus lastStatus_; | |
48 std::string postData_; | |
49 bool isVerbose_; | |
50 | |
51 void Setup(); | |
52 | |
53 void operator= (const HttpClient&); // Forbidden | |
54 | |
55 public: | |
56 HttpClient(const HttpClient& base); | |
57 | |
58 HttpClient(); | |
59 | |
60 ~HttpClient(); | |
61 | |
62 void SetUrl(const char* url) | |
63 { | |
64 url_ = std::string(url); | |
65 } | |
66 | |
67 void SetUrl(const std::string& url) | |
68 { | |
69 url_ = url; | |
70 } | |
71 | |
72 const std::string& GetUrl() const | |
73 { | |
74 return url_; | |
75 } | |
76 | |
77 void SetMethod(HttpMethod method) | |
78 { | |
79 method_ = method; | |
80 } | |
81 | |
82 HttpMethod GetMethod() const | |
83 { | |
84 return method_; | |
85 } | |
86 | |
87 std::string& AccessPostData() | |
88 { | |
89 return postData_; | |
90 } | |
91 | |
92 const std::string& AccessPostData() const | |
93 { | |
94 return postData_; | |
95 } | |
96 | |
97 void SetVerbose(bool isVerbose); | |
98 | |
99 bool IsVerbose() const | |
100 { | |
101 return isVerbose_; | |
102 } | |
103 | |
104 bool Apply(std::string& answer); | |
105 | |
106 bool Apply(Json::Value& answer); | |
107 | |
108 HttpStatus GetLastStatus() const | |
109 { | |
110 return lastStatus_; | |
111 } | |
112 | |
113 const char* GetLastStatusText() const; | |
114 | |
115 void SetCredentials(const char* username, | |
116 const char* password); | |
117 | |
118 static void GlobalInitialize(); | |
119 | |
120 static void GlobalFinalize(); | |
121 }; | |
122 } |