Pull merge from viewer-fbc
commit
bd482ab55e
|
|
@ -217,7 +217,8 @@ static void request(
|
|||
Injector* body_injector,
|
||||
LLCurl::ResponderPtr responder,
|
||||
const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
|
||||
const LLSD& headers = LLSD()
|
||||
const LLSD& headers = LLSD(),
|
||||
bool follow_redirects = true
|
||||
)
|
||||
{
|
||||
if (!LLHTTPClient::hasPump())
|
||||
|
|
@ -231,7 +232,7 @@ static void request(
|
|||
}
|
||||
LLPumpIO::chain_t chain;
|
||||
|
||||
LLURLRequest* req = new LLURLRequest(method, url);
|
||||
LLURLRequest* req = new LLURLRequest(method, url, follow_redirects);
|
||||
if(!req->isValid())//failed
|
||||
{
|
||||
if (responder)
|
||||
|
|
@ -334,7 +335,8 @@ void LLHTTPClient::getByteRange(
|
|||
S32 bytes,
|
||||
ResponderPtr responder,
|
||||
const LLSD& hdrs,
|
||||
const F32 timeout)
|
||||
const F32 timeout,
|
||||
bool follow_redirects /* = true */)
|
||||
{
|
||||
LLSD headers = hdrs;
|
||||
if(offset > 0 || bytes > 0)
|
||||
|
|
@ -342,37 +344,42 @@ void LLHTTPClient::getByteRange(
|
|||
std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);
|
||||
headers["Range"] = range;
|
||||
}
|
||||
request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers, follow_redirects);
|
||||
}
|
||||
|
||||
void LLHTTPClient::head(
|
||||
const std::string& url,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
const F32 timeout,
|
||||
bool follow_redirects /* = true */)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);
|
||||
}
|
||||
|
||||
void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout,
|
||||
bool follow_redirects /* = true */)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers, follow_redirects);
|
||||
}
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers,
|
||||
const F32 timeout, bool follow_redirects /* = true */)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);
|
||||
}
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout)
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout,
|
||||
bool follow_redirects /* = true */)
|
||||
{
|
||||
getHeaderOnly(url, responder, LLSD(), timeout);
|
||||
getHeaderOnly(url, responder, LLSD(), timeout, follow_redirects);
|
||||
}
|
||||
|
||||
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers,
|
||||
const F32 timeout, bool follow_redirects /* = true */)
|
||||
{
|
||||
LLURI uri;
|
||||
|
||||
uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query);
|
||||
get(uri.asString(), responder, headers, timeout);
|
||||
get(uri.asString(), responder, headers, timeout, follow_redirects);
|
||||
}
|
||||
|
||||
// A simple class for managing data returned from a curl http request.
|
||||
|
|
|
|||
|
|
@ -63,10 +63,15 @@ public:
|
|||
const std::string& url,
|
||||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr, const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS,
|
||||
bool follow_redirects = true);
|
||||
static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr,
|
||||
const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS,
|
||||
bool follow_redirects = true);
|
||||
static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
|
||||
static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
|
||||
|
||||
static void put(
|
||||
const std::string& url,
|
||||
|
|
@ -74,8 +79,10 @@ public:
|
|||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS,
|
||||
bool follow_redirects = true);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers,
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
|
||||
|
||||
static void post(
|
||||
const std::string& url,
|
||||
|
|
|
|||
|
|
@ -150,16 +150,19 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)
|
|||
return VERBS[action];
|
||||
}
|
||||
|
||||
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action) :
|
||||
mAction(action)
|
||||
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, bool follow_redirects /* = true */) :
|
||||
mAction(action),
|
||||
mFollowRedirects(follow_redirects)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
LLURLRequest::LLURLRequest(
|
||||
LLURLRequest::ERequestAction action,
|
||||
const std::string& url) :
|
||||
mAction(action)
|
||||
const std::string& url,
|
||||
bool follow_redirects /* = true */) :
|
||||
mAction(action),
|
||||
mFollowRedirects(follow_redirects)
|
||||
{
|
||||
initialize();
|
||||
setURL(url);
|
||||
|
|
@ -479,12 +482,18 @@ bool LLURLRequest::configure()
|
|||
case HTTP_HEAD:
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_HEADER, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_NOBODY, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
if (mFollowRedirects)
|
||||
{
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
}
|
||||
rv = true;
|
||||
break;
|
||||
case HTTP_GET:
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_HTTPGET, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
if (mFollowRedirects)
|
||||
{
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
}
|
||||
|
||||
// Set Accept-Encoding to allow response compression
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, "");
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public:
|
|||
*
|
||||
* @param action One of the ERequestAction enumerations.
|
||||
*/
|
||||
LLURLRequest(ERequestAction action);
|
||||
LLURLRequest(ERequestAction action, bool follow_redirects = true);
|
||||
|
||||
/**
|
||||
* @brief Constructor.
|
||||
|
|
@ -103,7 +103,7 @@ public:
|
|||
* @param action One of the ERequestAction enumerations.
|
||||
* @param url The url of the request. It should already be encoded.
|
||||
*/
|
||||
LLURLRequest(ERequestAction action, const std::string& url);
|
||||
LLURLRequest(ERequestAction action, const std::string& url, bool follow_redirects = true);
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
|
|
@ -219,10 +219,11 @@ protected:
|
|||
};
|
||||
EState mState;
|
||||
ERequestAction mAction;
|
||||
bool mFollowRedirects;
|
||||
LLURLRequestDetail* mDetail;
|
||||
LLIOPipe::ptr_t mCompletionCallback;
|
||||
S32 mRequestTransferedBytes;
|
||||
S32 mResponseTransferedBytes;
|
||||
S32 mRequestTransferedBytes;
|
||||
S32 mResponseTransferedBytes;
|
||||
|
||||
static CURLcode _sslCtxCallback(CURL * curl, void *sslctx, void *param);
|
||||
|
||||
|
|
|
|||
|
|
@ -1854,14 +1854,20 @@ public:
|
|||
|
||||
void LLPanelPeople::loadFacebookFriends()
|
||||
{
|
||||
LLHTTPClient::get(getFacebookConnectURL("/friend"), new FacebookFriendsResponder(this));
|
||||
const bool follow_redirects=false;
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
|
||||
LLHTTPClient::get(getFacebookConnectURL("/friend"), new FacebookFriendsResponder(this),
|
||||
LLSD(), timeout, follow_redirects);
|
||||
}
|
||||
|
||||
void LLPanelPeople::tryToReconnectToFacebook()
|
||||
{
|
||||
if (!mConnectedToFbc)
|
||||
{
|
||||
LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, false));
|
||||
const bool follow_redirects=false;
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
|
||||
LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, false),
|
||||
LLSD(), timeout, follow_redirects);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1881,7 +1887,8 @@ void LLPanelPeople::disconnectFromFacebook()
|
|||
|
||||
std::string LLPanelPeople::getFacebookConnectURL(const std::string& route)
|
||||
{
|
||||
static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect");
|
||||
//static std::string sFacebookConnectUrl = gAgent.getRegion()->getCapability("FacebookConnect");
|
||||
static std::string sFacebookConnectUrl = "https://pdp15.lindenlab.com/fbc/agent/" + gAgentID.asString(); // TEMPORARY HACK FOR FB DEMO - Cho
|
||||
std::string url = sFacebookConnectUrl + route;
|
||||
llinfos << url << llendl;
|
||||
return url;
|
||||
|
|
@ -1895,7 +1902,10 @@ void LLPanelPeople::onLoginFbcButtonClicked()
|
|||
}
|
||||
else
|
||||
{
|
||||
LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, true));
|
||||
const bool follow_redirects=false;
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS;
|
||||
LLHTTPClient::get(getFacebookConnectURL("/connection"), new FacebookConnectedResponder(this, true),
|
||||
LLSD(), timeout, follow_redirects);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -308,8 +308,8 @@ void LLCurl::Responder::errorWithContent(U32, std::string const&, LLSD const&) {
|
|||
void LLCurl::Responder::result(LLSD const&) {}
|
||||
LLCurl::Responder::~Responder() {}
|
||||
|
||||
void LLHTTPClient::get(const std::string&, const LLSD&, ResponderPtr, const LLSD&, const F32) {}
|
||||
void LLHTTPClient::get(const std::string&, LLPointer<LLCurl::Responder>, const LLSD&, const F32) {}
|
||||
void LLHTTPClient::get(const std::string&, const LLSD&, ResponderPtr, const LLSD&, const F32, bool) {}
|
||||
void LLHTTPClient::get(const std::string&, LLPointer<LLCurl::Responder>, const LLSD&, const F32, bool) {}
|
||||
|
||||
LLBufferStream::LLBufferStream(const LLChannelDescriptors& channels, LLBufferArray* buffer)
|
||||
: std::iostream(&mStreamBuf), mStreamBuf(channels, buffer) {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue