Mercurial > hg > orthanc
comparison Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 3392:ad434967a68c
renames
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Jun 2019 10:35:16 +0200 |
parents | 18cd4951fccc |
children | 2cd0369a156f |
comparison
equal
deleted
inserted
replaced
3391:df0f1821b3de | 3392:ad434967a68c |
---|---|
2058 | 2058 |
2059 | 2059 |
2060 | 2060 |
2061 #if HAS_ORTHANC_PLUGIN_HTTP_CLIENT == 1 | 2061 #if HAS_ORTHANC_PLUGIN_HTTP_CLIENT == 1 |
2062 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY == 1 | 2062 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY == 1 |
2063 class HttpClient::ChunkedBody : public boost::noncopyable | 2063 class HttpClient::RequestChunkedBody : public boost::noncopyable |
2064 { | 2064 { |
2065 private: | 2065 private: |
2066 static ChunkedBody& GetObject(void* body) | 2066 static RequestChunkedBody& GetObject(void* body) |
2067 { | 2067 { |
2068 assert(body != NULL); | 2068 assert(body != NULL); |
2069 return *reinterpret_cast<ChunkedBody*>(body); | 2069 return *reinterpret_cast<RequestChunkedBody*>(body); |
2070 } | 2070 } |
2071 | 2071 |
2072 IChunkedBody& body_; | 2072 IRequestChunkedBody& body_; |
2073 bool done_; | 2073 bool done_; |
2074 std::string chunk_; | 2074 std::string chunk_; |
2075 | 2075 |
2076 public: | 2076 public: |
2077 ChunkedBody(IChunkedBody& body) : | 2077 RequestChunkedBody(IRequestChunkedBody& body) : |
2078 body_(body), | 2078 body_(body), |
2079 done_(false) | 2079 done_(false) |
2080 { | 2080 { |
2081 } | 2081 } |
2082 | 2082 |
2095 return static_cast<uint32_t>(GetObject(body).chunk_.size()); | 2095 return static_cast<uint32_t>(GetObject(body).chunk_.size()); |
2096 } | 2096 } |
2097 | 2097 |
2098 static OrthancPluginErrorCode Next(void* body) | 2098 static OrthancPluginErrorCode Next(void* body) |
2099 { | 2099 { |
2100 ChunkedBody& that = GetObject(body); | 2100 RequestChunkedBody& that = GetObject(body); |
2101 | 2101 |
2102 if (that.done_) | 2102 if (that.done_) |
2103 { | 2103 { |
2104 return OrthancPluginErrorCode_BadSequenceOfCalls; | 2104 return OrthancPluginErrorCode_BadSequenceOfCalls; |
2105 } | 2105 } |
2186 chunkedBody_ = NULL; | 2186 chunkedBody_ = NULL; |
2187 } | 2187 } |
2188 | 2188 |
2189 | 2189 |
2190 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY == 1 | 2190 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY == 1 |
2191 void HttpClient::SetBody(IChunkedBody& body) | 2191 void HttpClient::SetBody(IRequestChunkedBody& body) |
2192 { | 2192 { |
2193 body_.clear(); | 2193 body_.clear(); |
2194 chunkedBody_ = &body; | 2194 chunkedBody_ = &body; |
2195 } | 2195 } |
2196 #endif | 2196 #endif |
2238 else | 2238 else |
2239 { | 2239 { |
2240 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY != 1 | 2240 #if HAS_ORTHANC_PLUGIN_HTTP_CHUNKED_BODY != 1 |
2241 error = OrthancPluginErrorCode_InternalError; | 2241 error = OrthancPluginErrorCode_InternalError; |
2242 #else | 2242 #else |
2243 ChunkedBody wrapper(*chunkedBody_); | 2243 RequestChunkedBody wrapper(*chunkedBody_); |
2244 | 2244 |
2245 error = OrthancPluginHttpClientChunkedBody( | 2245 error = OrthancPluginHttpClientChunkedBody( |
2246 GetGlobalContext(), | 2246 GetGlobalContext(), |
2247 *answerBody_, | 2247 *answerBody_, |
2248 *answerHeaders_, | 2248 *answerHeaders_, |
2258 certificateFile_.empty() ? NULL : certificateFile_.c_str(), | 2258 certificateFile_.empty() ? NULL : certificateFile_.c_str(), |
2259 certificateFile_.empty() ? NULL : certificateKeyFile_.c_str(), | 2259 certificateFile_.empty() ? NULL : certificateKeyFile_.c_str(), |
2260 certificateFile_.empty() ? NULL : certificateKeyPassword_.c_str(), | 2260 certificateFile_.empty() ? NULL : certificateKeyPassword_.c_str(), |
2261 pkcs11_ ? 1 : 0, | 2261 pkcs11_ ? 1 : 0, |
2262 &wrapper, | 2262 &wrapper, |
2263 ChunkedBody::IsDone, | 2263 RequestChunkedBody::IsDone, |
2264 ChunkedBody::GetChunkData, | 2264 RequestChunkedBody::GetChunkData, |
2265 ChunkedBody::GetChunkSize, | 2265 RequestChunkedBody::GetChunkSize, |
2266 ChunkedBody::Next); | 2266 RequestChunkedBody::Next); |
2267 #endif | 2267 #endif |
2268 } | 2268 } |
2269 | 2269 |
2270 if (error != OrthancPluginErrorCode_Success) | 2270 if (error != OrthancPluginErrorCode_Success) |
2271 { | 2271 { |