diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llmessage/llhttpclient.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llmessage/llhttpclient.cpp')
-rw-r--r-- | linden/indra/llmessage/llhttpclient.cpp | 81 |
1 files changed, 64 insertions, 17 deletions
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp index 88a6afd..a6041b4 100644 --- a/linden/indra/llmessage/llhttpclient.cpp +++ b/linden/indra/llmessage/llhttpclient.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | /** | 1 | /** |
2 | * @file llhttpclient.cpp | 2 | * @file llhttpclient.cpp |
3 | * @brief Implementation of classes for making HTTP requests. | 3 | * @brief Implementation of classes for making HTTP requests. |
4 | * | 4 | * |
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -310,9 +311,13 @@ void LLHTTPClient::getByteRange( | |||
310 | request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers); | 311 | request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers); |
311 | } | 312 | } |
312 | 313 | ||
313 | void LLHTTPClient::head(const std::string& url, ResponderPtr responder, const F32 timeout) | 314 | void LLHTTPClient::head( |
315 | const std::string& url, | ||
316 | ResponderPtr responder, | ||
317 | const LLSD& headers, | ||
318 | const F32 timeout) | ||
314 | { | 319 | { |
315 | request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout); | 320 | request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers); |
316 | } | 321 | } |
317 | 322 | ||
318 | void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout) | 323 | void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout) |
@@ -397,6 +402,14 @@ LLSD LLHTTPClient::blockingGet(const std::string& url) | |||
397 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curl_error_buffer); | 402 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curl_error_buffer); |
398 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); | 403 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); |
399 | 404 | ||
405 | struct curl_slist *header_list = NULL; | ||
406 | header_list = curl_slist_append(header_list, "Accept: application/llsd+xml"); | ||
407 | CURLcode curl_result = curl_easy_setopt(curlp, CURLOPT_HTTPHEADER, header_list); | ||
408 | if ( curl_result != CURLE_OK ) | ||
409 | { | ||
410 | llinfos << "Curl is hosed - can't add Accept header for llsd+xml" << llendl; | ||
411 | } | ||
412 | |||
400 | LLSD response = LLSD::emptyMap(); | 413 | LLSD response = LLSD::emptyMap(); |
401 | 414 | ||
402 | S32 curl_success = curl_easy_perform(curlp); | 415 | S32 curl_success = curl_easy_perform(curlp); |
@@ -418,44 +431,77 @@ LLSD LLHTTPClient::blockingGet(const std::string& url) | |||
418 | response["body"] = http_buffer.asLLSD(); | 431 | response["body"] = http_buffer.asLLSD(); |
419 | } | 432 | } |
420 | 433 | ||
434 | if(header_list) | ||
435 | { // free the header list | ||
436 | curl_slist_free_all(header_list); | ||
437 | header_list = NULL; | ||
438 | } | ||
439 | |||
421 | curl_easy_cleanup(curlp); | 440 | curl_easy_cleanup(curlp); |
422 | 441 | ||
423 | return response; | 442 | return response; |
424 | } | 443 | } |
425 | 444 | ||
426 | void LLHTTPClient::put(const std::string& url, const LLSD& body, ResponderPtr responder, const F32 timeout) | 445 | void LLHTTPClient::put( |
446 | const std::string& url, | ||
447 | const LLSD& body, | ||
448 | ResponderPtr responder, | ||
449 | const LLSD& headers, | ||
450 | const F32 timeout) | ||
427 | { | 451 | { |
428 | request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, timeout); | 452 | request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, timeout, headers); |
429 | } | 453 | } |
430 | 454 | ||
431 | void LLHTTPClient::post(const std::string& url, const LLSD& body, ResponderPtr responder, const F32 timeout) | 455 | void LLHTTPClient::post( |
456 | const std::string& url, | ||
457 | const LLSD& body, | ||
458 | ResponderPtr responder, | ||
459 | const LLSD& headers, | ||
460 | const F32 timeout) | ||
432 | { | 461 | { |
433 | request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, timeout); | 462 | request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, timeout, headers); |
434 | } | 463 | } |
435 | 464 | ||
436 | void LLHTTPClient::postRaw(const std::string& url, const U8* data, S32 size, ResponderPtr responder, const F32 timeout) | 465 | void LLHTTPClient::postRaw( |
466 | const std::string& url, | ||
467 | const U8* data, | ||
468 | S32 size, | ||
469 | ResponderPtr responder, | ||
470 | const LLSD& headers, | ||
471 | const F32 timeout) | ||
437 | { | 472 | { |
438 | request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, timeout); | 473 | request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, timeout, headers); |
439 | } | 474 | } |
440 | 475 | ||
441 | void LLHTTPClient::postFile(const std::string& url, const std::string& filename, ResponderPtr responder, const F32 timeout) | 476 | void LLHTTPClient::postFile( |
477 | const std::string& url, | ||
478 | const std::string& filename, | ||
479 | ResponderPtr responder, | ||
480 | const LLSD& headers, | ||
481 | const F32 timeout) | ||
442 | { | 482 | { |
443 | request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, timeout); | 483 | request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, timeout, headers); |
444 | } | 484 | } |
445 | 485 | ||
446 | void LLHTTPClient::postFile(const std::string& url, const LLUUID& uuid, | 486 | void LLHTTPClient::postFile( |
447 | LLAssetType::EType asset_type, ResponderPtr responder, const F32 timeout) | 487 | const std::string& url, |
488 | const LLUUID& uuid, | ||
489 | LLAssetType::EType asset_type, | ||
490 | ResponderPtr responder, | ||
491 | const LLSD& headers, | ||
492 | const F32 timeout) | ||
448 | { | 493 | { |
449 | request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, timeout); | 494 | request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, timeout, headers); |
450 | } | 495 | } |
451 | 496 | ||
452 | // static | 497 | // static |
453 | void LLHTTPClient::del( | 498 | void LLHTTPClient::del( |
454 | const std::string& url, | 499 | const std::string& url, |
455 | ResponderPtr responder, | 500 | ResponderPtr responder, |
501 | const LLSD& headers, | ||
456 | const F32 timeout) | 502 | const F32 timeout) |
457 | { | 503 | { |
458 | request(url, LLURLRequest::HTTP_DELETE, NULL, responder, timeout); | 504 | request(url, LLURLRequest::HTTP_DELETE, NULL, responder, timeout, headers); |
459 | } | 505 | } |
460 | 506 | ||
461 | // static | 507 | // static |
@@ -463,9 +509,10 @@ void LLHTTPClient::move( | |||
463 | const std::string& url, | 509 | const std::string& url, |
464 | const std::string& destination, | 510 | const std::string& destination, |
465 | ResponderPtr responder, | 511 | ResponderPtr responder, |
512 | const LLSD& hdrs, | ||
466 | const F32 timeout) | 513 | const F32 timeout) |
467 | { | 514 | { |
468 | LLSD headers; | 515 | LLSD headers = hdrs; |
469 | headers["Destination"] = destination; | 516 | headers["Destination"] = destination; |
470 | request(url, LLURLRequest::HTTP_MOVE, NULL, responder, timeout, headers); | 517 | request(url, LLURLRequest::HTTP_MOVE, NULL, responder, timeout, headers); |
471 | } | 518 | } |