diff options
author | Rider Linden <rider@lindenlab.com> | 2015-06-05 15:19:24 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-06-05 15:19:24 -0700 |
commit | daf4d167b66c6124b96dee585b43060e2ea06b42 (patch) | |
tree | 78c6c92c9cc4bb0163df1dd054604232bd100f6b /indra/llcorehttp | |
parent | d0d58c41b48f8a2a0e18610b577059ee8419be5c (diff) |
Added a seek method to LLCore::Http for data rewind.
A couple of minor changes to merchant out box in hopes that the would fix the issues.
Diffstat (limited to 'indra/llcorehttp')
-rwxr-xr-x | indra/llcorehttp/_httpoprequest.cpp | 35 | ||||
-rwxr-xr-x | indra/llcorehttp/_httpoprequest.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 3b6647882e..3a51f898ab 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -515,6 +515,10 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_READFUNCTION); code = curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, this); check_curl_easy_code(code, CURLOPT_READDATA); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKFUNCTION, seekCallback); + check_curl_easy_code(code, CURLOPT_SEEKFUNCTION); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKDATA, this); + check_curl_easy_code(code, CURLOPT_SEEKDATA); code = curl_easy_setopt(mCurlHandle, CURLOPT_COOKIEFILE, ""); check_curl_easy_code(code, CURLOPT_COOKIEFILE); @@ -819,6 +823,37 @@ size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void return read_size; } + +int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) +{ + HttpOpRequest * op(static_cast<HttpOpRequest *>(userdata)); + + if (!op->mReqBody) + { + return 0; + } + + size_t newPos = 0; + if (origin == SEEK_SET) + newPos = offset; + else if (origin == SEEK_END) + newPos = static_cast<curl_off_t>(op->mReqBody->size()) + offset; + else if (origin == SEEK_CUR) + newPos = static_cast<curl_off_t>(op->mCurlBodyPos) + offset; + else + return 2; + + if ((newPos < 0) || (newPos >= op->mReqBody->size())) + { + LL_WARNS(LOG_CORE) << "Attempt to seek to position outside post body." << LL_ENDL; + return 2; + } + + op->mCurlBodyPos = (size_t)newPos; + + return 0; +} + size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, void * userdata) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index ca40898a81..b1bb101bea 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -175,6 +175,7 @@ protected: // static size_t writeCallback(void * data, size_t size, size_t nmemb, void * userdata); static size_t readCallback(void * data, size_t size, size_t nmemb, void * userdata); + static int seekCallback(void *data, curl_off_t offset, int origin); static size_t headerCallback(void * data, size_t size, size_t nmemb, void * userdata); static CURLcode curlSslCtxCallback(CURL *curl, void *ssl_ctx, void *userptr); static int sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param); |