Implement all aisv3 HTTP requests. Added PATCH and COPY methods.
This commit is contained in:
@@ -803,6 +803,23 @@ void CurlEasyRequest::setPut(U32 size, bool keepalive)
|
||||
setopt(CURLOPT_INFILESIZE, size);
|
||||
}
|
||||
|
||||
void CurlEasyRequest::setPatch(U32 size, bool keepalive)
|
||||
{
|
||||
DoutCurl("PATCH size is " << size << " bytes.");
|
||||
mContentLength = size;
|
||||
|
||||
// The server never replies with 100-continue, so suppress the "Expect: 100-continue" header that libcurl adds by default.
|
||||
addHeader("Expect:");
|
||||
if (size > 0 && keepalive)
|
||||
{
|
||||
addHeader("Connection: keep-alive");
|
||||
addHeader("Keep-alive: 300");
|
||||
}
|
||||
setopt(CURLOPT_UPLOAD, 1);
|
||||
setopt(CURLOPT_INFILESIZE, size);\
|
||||
setopt(CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||
}
|
||||
|
||||
void CurlEasyRequest::setPost(AIPostFieldPtr const& postdata, U32 size, bool keepalive)
|
||||
{
|
||||
llassert_always(postdata->data());
|
||||
|
||||
@@ -222,6 +222,7 @@ class CurlEasyRequest : public CurlEasyHandle {
|
||||
void setPost_raw(U32 size, char const* data, bool keepalive);
|
||||
public:
|
||||
void setPut(U32 size, bool keepalive = true);
|
||||
void setPatch(U32 size, bool keepalive = true);
|
||||
void setPost(U32 size, bool keepalive = true) { setPost_raw(size, NULL, keepalive); }
|
||||
void setPost(AIPostFieldPtr const& postdata, U32 size, bool keepalive = true);
|
||||
void setPost(char const* data, U32 size, bool keepalive = true) { setPost(new AIPostField(data), size, keepalive); }
|
||||
|
||||
@@ -908,6 +908,7 @@ AIHTTPTimeoutPolicy const* AIHTTPTimeoutPolicy::getTimeoutPolicyByName(std::stri
|
||||
P(assetReportHandler);
|
||||
P(authHandler);
|
||||
P2(baseCapabilitiesComplete, transfer_18s_connect_5s);
|
||||
P2(baseCapabilitiesCompleteTracker, transfer_18s_connect_5s);
|
||||
P(blockingLLSDPost);
|
||||
P(blockingLLSDGet);
|
||||
P(blockingRawGet);
|
||||
@@ -924,7 +925,6 @@ P(fetchScriptLimitsRegionInfoResponder);
|
||||
P(fetchScriptLimitsRegionSummaryResponder);
|
||||
P(fnPtrResponder);
|
||||
P(floaterPermsResponder);
|
||||
P2(gamingDataReceived, transfer_22s_connect_10s);
|
||||
P2(groupProposalBallotResponder, transfer_300s);
|
||||
P(homeLocationResponder);
|
||||
P2(HTTPGetResponder, reply_15s);
|
||||
@@ -954,7 +954,7 @@ P(requestAgentUpdateAppearance);
|
||||
P2(incrementCofVersionResponder_timeouts, transfer_30s_connect_10s);
|
||||
P(responderIgnore);
|
||||
P(setDisplayNameResponder);
|
||||
P2(simulatorFeaturesReceived, transfer_22s_connect_10s);
|
||||
P2(baseFeaturesReceived, transfer_22s_connect_10s);
|
||||
P2(startGroupVoteResponder, transfer_300s);
|
||||
P(translationReceiver);
|
||||
P(uploadModelPremissionsResponder);
|
||||
|
||||
@@ -727,6 +727,11 @@ void LLHTTPClient::putRaw(const std::string& url, const U8* data, S32 size, Resp
|
||||
request(url, HTTP_PUT, new RawInjector(data, size), responder, headers, NULL/*,*/ DEBUG_CURLIO_PARAM(debug), no_keep_alive, no_does_authentication, no_allow_compressed_reply);
|
||||
}
|
||||
|
||||
void LLHTTPClient::patch(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive, AIStateMachine* parent, AIStateMachine::state_type new_parent_state)
|
||||
{
|
||||
request(url, HTTP_PATCH, new LLSDInjector(body), responder, headers, NULL/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, no_does_authentication, allow_compressed_reply, parent, new_parent_state);
|
||||
}
|
||||
|
||||
void LLHTTPClient::post(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug), EKeepAlive keepalive, AIStateMachine* parent, AIStateMachine::state_type new_parent_state)
|
||||
{
|
||||
request(url, HTTP_POST, new LLSDInjector(body), responder, headers, NULL/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, no_does_authentication, allow_compressed_reply, parent, new_parent_state);
|
||||
@@ -780,3 +785,10 @@ void LLHTTPClient::move(std::string const& url, std::string const& destination,
|
||||
headers.addHeader("Destination", destination);
|
||||
request(url, HTTP_MOVE, NULL, responder, headers, NULL/*,*/ DEBUG_CURLIO_PARAM(debug));
|
||||
}
|
||||
|
||||
// static
|
||||
void LLHTTPClient::copy(std::string const& url, std::string const& destination, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug))
|
||||
{
|
||||
headers.addHeader("Destination", destination);
|
||||
request(url, HTTP_COPY, NULL, responder, headers, NULL/*,*/ DEBUG_CURLIO_PARAM(debug));
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ public:
|
||||
HTTP_POST,
|
||||
HTTP_DELETE,
|
||||
HTTP_MOVE, // Caller will need to set 'Destination' header
|
||||
HTTP_PATCH,
|
||||
HTTP_COPY,
|
||||
REQUEST_ACTION_COUNT
|
||||
};
|
||||
|
||||
@@ -499,6 +501,10 @@ public:
|
||||
static void getHeaderOnly(std::string const& url, ResponderHeadersOnly* responder/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off))
|
||||
{ AIHTTPHeaders headers; getHeaderOnly(url, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug)); }
|
||||
|
||||
static void patch(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off), EKeepAlive keepalive = keep_alive, AIStateMachine* parent = NULL, U32 new_parent_state = 0);
|
||||
static void patch(std::string const& url, LLSD const& body, ResponderPtr responder/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off), EKeepAlive keepalive = keep_alive, AIStateMachine* parent = NULL, U32 new_parent_state = 0)
|
||||
{ AIHTTPHeaders headers; patch(url, body, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, parent, new_parent_state); }
|
||||
|
||||
static void post(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off), EKeepAlive keepalive = keep_alive, AIStateMachine* parent = NULL, U32 new_parent_state = 0);
|
||||
static void post(std::string const& url, LLSD const& body, ResponderPtr responder/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off), EKeepAlive keepalive = keep_alive, AIStateMachine* parent = NULL, U32 new_parent_state = 0)
|
||||
{ AIHTTPHeaders headers; post(url, body, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug), keepalive, parent, new_parent_state); }
|
||||
@@ -550,6 +556,12 @@ public:
|
||||
|
||||
//@}
|
||||
|
||||
static void copy(std::string const& url, std::string const& destination, ResponderPtr responder, AIHTTPHeaders& headers/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off));
|
||||
static void copy(std::string const& url, std::string const& destination, ResponderPtr responder/*,*/ DEBUG_CURLIO_PARAM(EDebugCurl debug = debug_off))
|
||||
{
|
||||
AIHTTPHeaders headers; copy(url, destination, responder, headers/*,*/ DEBUG_CURLIO_PARAM(debug));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Blocking HTTP GET that returns an LLSD map of status and body.
|
||||
*
|
||||
|
||||
@@ -97,7 +97,7 @@ void LLURLRequest::initialize_impl(void)
|
||||
useProxy(false);
|
||||
}
|
||||
|
||||
if (mAction == LLHTTPClient::HTTP_PUT || mAction == LLHTTPClient::HTTP_POST)
|
||||
if (mAction == LLHTTPClient::HTTP_PUT || mAction == LLHTTPClient::HTTP_POST || mAction == LLHTTPClient::HTTP_PATCH)
|
||||
{
|
||||
// If the Content-Type header was passed in we defer to the caller's wisdom,
|
||||
// but if they did not specify a Content-Type, then ask the injector.
|
||||
@@ -237,7 +237,16 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, mNoCompression ? "identity" : "");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
|
||||
case LLHTTPClient::HTTP_PATCH:
|
||||
|
||||
curlEasyRequest_w->setPatch(mBodySize, mKeepAlive);
|
||||
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, mNoCompression ? "identity" : "");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case LLHTTPClient::HTTP_POST:
|
||||
|
||||
// Set the handle for an http post
|
||||
@@ -254,6 +263,12 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case LLHTTPClient::HTTP_COPY:
|
||||
// Set the handle for an http copy
|
||||
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "COPY");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case LLHTTPClient::HTTP_MOVE:
|
||||
// Set the handle for an http post
|
||||
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
|
||||
|
||||
Reference in New Issue
Block a user