diff options
author | Armin Weatherwax | 2009-06-26 09:39:58 +0200 |
---|---|---|
committer | Armin Weatherwax | 2009-07-11 13:42:35 +0200 |
commit | 7067b31a6114089217e482bfecc58fd56bed4272 (patch) | |
tree | e0bb99a42c64cdb75e9ca15a38bc1171377c7739 /linden/indra/newview/hippoRestRequest.cpp | |
parent | Updated URL for Mac OpenAL libs package. (diff) | |
download | meta-impy-7067b31a6114089217e482bfecc58fd56bed4272.zip meta-impy-7067b31a6114089217e482bfecc58fd56bed4272.tar.gz meta-impy-7067b31a6114089217e482bfecc58fd56bed4272.tar.bz2 meta-impy-7067b31a6114089217e482bfecc58fd56bed4272.tar.xz |
BROKEN logoff/relog crashing inconsistently on various startup states.
Diffstat (limited to 'linden/indra/newview/hippoRestRequest.cpp')
-rw-r--r-- | linden/indra/newview/hippoRestRequest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/linden/indra/newview/hippoRestRequest.cpp b/linden/indra/newview/hippoRestRequest.cpp new file mode 100644 index 0000000..ab8a557 --- /dev/null +++ b/linden/indra/newview/hippoRestRequest.cpp | |||
@@ -0,0 +1,54 @@ | |||
1 | |||
2 | |||
3 | #include "hippoRestRequest.h" | ||
4 | |||
5 | #ifndef CURL_STATICLIB | ||
6 | #define CURL_STATICLIB 1 | ||
7 | #endif | ||
8 | #include <curl/curl.h> | ||
9 | |||
10 | #include <stdtypes.h> | ||
11 | #include <llerror.h> | ||
12 | |||
13 | |||
14 | static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) | ||
15 | { | ||
16 | std::string *result = (std::string*)userData; | ||
17 | size_t bytes = (size * nmemb); | ||
18 | result->append((char*)ptr, bytes); | ||
19 | return nmemb; | ||
20 | } | ||
21 | |||
22 | |||
23 | //static | ||
24 | int HippoRestRequest::getBlocking(const std::string &url, std::string *result) | ||
25 | { | ||
26 | llinfos << "Requesting: " << url << llendl; | ||
27 | |||
28 | char curlErrorBuffer[CURL_ERROR_SIZE]; | ||
29 | CURL* curlp = curl_easy_init(); | ||
30 | |||
31 | curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts | ||
32 | curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds | ||
33 | |||
34 | curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); | ||
35 | curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); | ||
36 | curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); | ||
37 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); | ||
38 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); | ||
39 | |||
40 | *result = ""; | ||
41 | S32 curlSuccess = curl_easy_perform(curlp); | ||
42 | S32 httpStatus = 499; | ||
43 | curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); | ||
44 | |||
45 | if (curlSuccess != 0) { | ||
46 | llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; | ||
47 | } else if (httpStatus != 200) { | ||
48 | llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; | ||
49 | } | ||
50 | |||
51 | curl_easy_cleanup(curlp); | ||
52 | return httpStatus; | ||
53 | } | ||
54 | |||