Mercurial > hg > orthanc
comparison Core/HttpClient.cpp @ 3392:ad434967a68c
renames
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Jun 2019 10:35:16 +0200 |
parents | a48d652f1500 |
children | 2cd0369a156f |
comparison
equal
deleted
inserted
replaced
3391:df0f1821b3de | 3392:ad434967a68c |
---|---|
199 return isChunkedTransfer_; | 199 return isChunkedTransfer_; |
200 } | 200 } |
201 }; | 201 }; |
202 | 202 |
203 | 203 |
204 class HttpClient::CurlChunkedBody : public boost::noncopyable | 204 class HttpClient::CurlRequestChunkedBody : public boost::noncopyable |
205 { | 205 { |
206 private: | 206 private: |
207 HttpClient::IChunkedBody* body_; | 207 HttpClient::IRequestChunkedBody* body_; |
208 std::string buffer_; | 208 std::string buffer_; |
209 | 209 |
210 size_t CallbackInternal(char* curlBuffer, | 210 size_t CallbackInternal(char* curlBuffer, |
211 size_t curlBufferSize) | 211 size_t curlBufferSize) |
212 { | 212 { |
213 if (body_ == NULL) | 213 if (body_ == NULL) |
241 | 241 |
242 return s; | 242 return s; |
243 } | 243 } |
244 | 244 |
245 public: | 245 public: |
246 CurlChunkedBody() : | 246 CurlRequestChunkedBody() : |
247 body_(NULL) | 247 body_(NULL) |
248 { | 248 { |
249 } | 249 } |
250 | 250 |
251 void SetBody(HttpClient::IChunkedBody& body) | 251 void SetBody(HttpClient::IRequestChunkedBody& body) |
252 { | 252 { |
253 body_ = &body; | 253 body_ = &body; |
254 buffer_.clear(); | 254 buffer_.clear(); |
255 } | 255 } |
256 | 256 |
270 size_t nitems, | 270 size_t nitems, |
271 void *userdata) | 271 void *userdata) |
272 { | 272 { |
273 try | 273 try |
274 { | 274 { |
275 HttpClient::CurlChunkedBody* body = reinterpret_cast<HttpClient::CurlChunkedBody*>(userdata); | 275 HttpClient::CurlRequestChunkedBody* body = reinterpret_cast<HttpClient::CurlRequestChunkedBody*>(userdata); |
276 | 276 |
277 if (body == NULL) | 277 if (body == NULL) |
278 { | 278 { |
279 throw OrthancException(ErrorCode_NullPointer); | 279 throw OrthancException(ErrorCode_NullPointer); |
280 } | 280 } |
402 { | 402 { |
403 CURL* curl_; | 403 CURL* curl_; |
404 CurlHeaders defaultPostHeaders_; | 404 CurlHeaders defaultPostHeaders_; |
405 CurlHeaders defaultChunkedHeaders_; | 405 CurlHeaders defaultChunkedHeaders_; |
406 CurlHeaders userHeaders_; | 406 CurlHeaders userHeaders_; |
407 CurlChunkedBody chunkedBody_; | 407 CurlRequestChunkedBody chunkedBody_; |
408 }; | 408 }; |
409 | 409 |
410 | 410 |
411 void HttpClient::ThrowException(HttpStatus status) | 411 void HttpClient::ThrowException(HttpStatus status) |
412 { | 412 { |
606 body_ = data; | 606 body_ = data; |
607 pimpl_->chunkedBody_.Clear(); | 607 pimpl_->chunkedBody_.Clear(); |
608 } | 608 } |
609 | 609 |
610 | 610 |
611 void HttpClient::SetBody(IChunkedBody& body) | 611 void HttpClient::SetBody(IRequestChunkedBody& body) |
612 { | 612 { |
613 body_.clear(); | 613 body_.clear(); |
614 pimpl_->chunkedBody_.SetBody(body); | 614 pimpl_->chunkedBody_.SetBody(body); |
615 } | 615 } |
616 | 616 |
827 LOG(INFO) << "For performance, the HTTP header \"Expect\" should be set to empty string in POST/PUT requests"; | 827 LOG(INFO) << "For performance, the HTTP header \"Expect\" should be set to empty string in POST/PUT requests"; |
828 } | 828 } |
829 | 829 |
830 if (pimpl_->chunkedBody_.IsValid()) | 830 if (pimpl_->chunkedBody_.IsValid()) |
831 { | 831 { |
832 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_READFUNCTION, CurlChunkedBody::Callback)); | 832 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_READFUNCTION, CurlRequestChunkedBody::Callback)); |
833 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_READDATA, &pimpl_->chunkedBody_)); | 833 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_READDATA, &pimpl_->chunkedBody_)); |
834 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POST, 1L)); | 834 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POST, 1L)); |
835 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, -1L)); | 835 CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, -1L)); |
836 | 836 |
837 if (pimpl_->userHeaders_.IsEmpty()) | 837 if (pimpl_->userHeaders_.IsEmpty()) |