diff options
Diffstat (limited to 'indra/llmessage/llurlrequest.cpp')
-rwxr-xr-x | indra/llmessage/llurlrequest.cpp | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index 683065357d..ae4c40cdb0 100755 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -40,7 +40,6 @@ #include "llstring.h" #include "apr_env.h" #include "llapr.h" -static const U32 HTTP_STATUS_PIPE_ERROR = 499; /** * String constants @@ -48,11 +47,12 @@ static const U32 HTTP_STATUS_PIPE_ERROR = 499; const std::string CONTEXT_DEST_URI_SD_LABEL("dest_uri"); const std::string CONTEXT_TRANSFERED_BYTES("transfered_bytes"); +// These are defined in llhttpnode.h/llhttpnode.cpp +extern const std::string CONTEXT_REQUEST; +extern const std::string CONTEXT_RESPONSE; static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user); - - /** * class LLURLRequestDetail */ @@ -130,27 +130,8 @@ CURLcode LLURLRequest::_sslCtxCallback(CURL * curl, void *sslctx, void *param) * class LLURLRequest */ -// static -std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action) -{ - static const std::string VERBS[] = - { - "(invalid)", - "HEAD", - "GET", - "PUT", - "POST", - "DELETE", - "MOVE" - }; - if(((S32)action <=0) || ((S32)action >= REQUEST_ACTION_COUNT)) - { - return VERBS[0]; - } - return VERBS[action]; -} -LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, bool follow_redirects /* = true */) : +LLURLRequest::LLURLRequest(EHTTPMethod action, bool follow_redirects /* = true */) : mAction(action), mFollowRedirects(follow_redirects) { @@ -158,7 +139,7 @@ LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, bool follow_redi } LLURLRequest::LLURLRequest( - LLURLRequest::ERequestAction action, + EHTTPMethod action, const std::string& url, bool follow_redirects /* = true */) : mAction(action), @@ -183,12 +164,17 @@ void LLURLRequest::setURL(const std::string& url) } } -std::string LLURLRequest::getURL() const +const std::string& LLURLRequest::getURL() const { return mDetail->mURL; } -void LLURLRequest::addHeader(const char* header) +void LLURLRequest::addHeader(const std::string& header, const std::string& value /* = "" */) +{ + mDetail->mCurlRequest->slist_append(header, value); +} + +void LLURLRequest::addHeaderRaw(const char* header) { mDetail->mCurlRequest->slist_append(header); } @@ -275,7 +261,7 @@ LLIOPipe::EStatus LLURLRequest::handleError( LLURLRequestComplete* complete = NULL; complete = (LLURLRequestComplete*)mCompletionCallback.get(); complete->httpStatus( - HTTP_STATUS_PIPE_ERROR, + HTTP_INTERNAL_ERROR, LLIOPipe::lookupStatusString(status)); complete->responseStatus(status); pump->respond(complete); @@ -503,21 +489,32 @@ bool LLURLRequest::configure() case HTTP_PUT: // Disable the expect http 1.1 extension. POST and PUT default // to turning this on, and I am not too sure what it means. - addHeader("Expect:"); + addHeader(HTTP_OUT_HEADER_EXPECT); + + mDetail->mCurlRequest->setopt(CURLOPT_UPLOAD, 1); + mDetail->mCurlRequest->setopt(CURLOPT_INFILESIZE, bytes); + rv = true; + break; + + case HTTP_PATCH: + // Disable the expect http 1.1 extension. POST and PUT default + // to turning this on, and I am not too sure what it means. + addHeader(HTTP_OUT_HEADER_EXPECT); mDetail->mCurlRequest->setopt(CURLOPT_UPLOAD, 1); mDetail->mCurlRequest->setopt(CURLOPT_INFILESIZE, bytes); + mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "PATCH"); rv = true; break; case HTTP_POST: // Disable the expect http 1.1 extension. POST and PUT default // to turning this on, and I am not too sure what it means. - addHeader("Expect:"); + addHeader(HTTP_OUT_HEADER_EXPECT); // Disable the content type http header. // *FIX: what should it be? - addHeader("Content-Type:"); + addHeader(HTTP_OUT_HEADER_CONTENT_TYPE); // Set the handle for an http post mDetail->mCurlRequest->setPost(NULL, bytes); @@ -528,13 +525,19 @@ bool LLURLRequest::configure() break; case HTTP_DELETE: - // Set the handle for an http post + // Set the handle for an http delete mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE"); rv = true; break; + case HTTP_COPY: + // Set the handle for an http copy + mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "COPY"); + rv = true; + break; + case HTTP_MOVE: - // Set the handle for an http post + // Set the handle for an http move mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE"); // *NOTE: should we check for the Destination header? rv = true; @@ -647,7 +650,7 @@ static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user) S32 status_code = atoi(status.c_str()); if (status_code > 0) { - complete->httpStatus((U32)status_code, reason); + complete->httpStatus(status_code, reason); return header_len; } } |