diff options
Diffstat (limited to 'linden/indra/newview/hippoRestRequest.cpp')
-rw-r--r-- | linden/indra/newview/hippoRestRequest.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/linden/indra/newview/hippoRestRequest.cpp b/linden/indra/newview/hippoRestRequest.cpp index ab8a557..cf518de 100644 --- a/linden/indra/newview/hippoRestRequest.cpp +++ b/linden/indra/newview/hippoRestRequest.cpp | |||
@@ -1,54 +1,54 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "hippoRestRequest.h" | 3 | #include "hippoRestRequest.h" |
4 | 4 | ||
5 | #ifndef CURL_STATICLIB | 5 | #ifndef CURL_STATICLIB |
6 | #define CURL_STATICLIB 1 | 6 | #define CURL_STATICLIB 1 |
7 | #endif | 7 | #endif |
8 | #include <curl/curl.h> | 8 | #include <curl/curl.h> |
9 | 9 | ||
10 | #include <stdtypes.h> | 10 | #include <stdtypes.h> |
11 | #include <llerror.h> | 11 | #include <llerror.h> |
12 | 12 | ||
13 | 13 | ||
14 | static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) | 14 | static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) |
15 | { | 15 | { |
16 | std::string *result = (std::string*)userData; | 16 | std::string *result = (std::string*)userData; |
17 | size_t bytes = (size * nmemb); | 17 | size_t bytes = (size * nmemb); |
18 | result->append((char*)ptr, bytes); | 18 | result->append((char*)ptr, bytes); |
19 | return nmemb; | 19 | return nmemb; |
20 | } | 20 | } |
21 | 21 | ||
22 | 22 | ||
23 | //static | 23 | //static |
24 | int HippoRestRequest::getBlocking(const std::string &url, std::string *result) | 24 | int HippoRestRequest::getBlocking(const std::string &url, std::string *result) |
25 | { | 25 | { |
26 | llinfos << "Requesting: " << url << llendl; | 26 | llinfos << "Requesting: " << url << llendl; |
27 | 27 | ||
28 | char curlErrorBuffer[CURL_ERROR_SIZE]; | 28 | char curlErrorBuffer[CURL_ERROR_SIZE]; |
29 | CURL* curlp = curl_easy_init(); | 29 | CURL* curlp = curl_easy_init(); |
30 | 30 | ||
31 | curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts | 31 | curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts |
32 | curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds | 32 | curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds |
33 | 33 | ||
34 | curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); | 34 | curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); |
35 | curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); | 35 | curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); |
36 | curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); | 36 | curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); |
37 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); | 37 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); |
38 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); | 38 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); |
39 | 39 | ||
40 | *result = ""; | 40 | *result = ""; |
41 | S32 curlSuccess = curl_easy_perform(curlp); | 41 | S32 curlSuccess = curl_easy_perform(curlp); |
42 | S32 httpStatus = 499; | 42 | S32 httpStatus = 499; |
43 | curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); | 43 | curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); |
44 | 44 | ||
45 | if (curlSuccess != 0) { | 45 | if (curlSuccess != 0) { |
46 | llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; | 46 | llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; |
47 | } else if (httpStatus != 200) { | 47 | } else if (httpStatus != 200) { |
48 | llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; | 48 | llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; |
49 | } | 49 | } |
50 | 50 | ||
51 | curl_easy_cleanup(curlp); | 51 | curl_easy_cleanup(curlp); |
52 | return httpStatus; | 52 | return httpStatus; |
53 | } | 53 | } |
54 | 54 | ||