Curl work in progress.
Minor changes like comment fixes and addition of accessors that will be needed for future commits. Also removed Responder::fatalError as it was never used.
This commit is contained in:
@@ -479,12 +479,6 @@ void Responder::completedRaw(U32 status, std::string const& reason, LLChannelDes
|
||||
completed(status, reason, content);
|
||||
}
|
||||
|
||||
void Responder::fatalError(std::string const& reason)
|
||||
{
|
||||
llwarns << "Responder::fatalError(\"" << reason << "\") is called (" << mURL << "). Passing it to Responder::completed with fake HTML error status and empty HTML body!" << llendl;
|
||||
completed(U32_MAX, reason, LLSD());
|
||||
}
|
||||
|
||||
// virtual
|
||||
void Responder::completed(U32 status, std::string const& reason, LLSD const& content)
|
||||
{
|
||||
@@ -1364,7 +1358,7 @@ void CurlResponderBuffer::prepRequest(AICurlEasyRequest_wat& curl_easy_request_w
|
||||
curl_easy_request_w->setHeaderCallback(&curlHeaderCallback, lockobj);
|
||||
|
||||
// Allow up to ten redirects.
|
||||
if (responder && responder->followRedir())
|
||||
if (responder->followRedir())
|
||||
{
|
||||
curl_easy_request_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_request_w->setopt(CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);
|
||||
|
||||
@@ -204,7 +204,7 @@ class Responder : public AICurlResponderBufferEvents {
|
||||
Responder(void);
|
||||
virtual ~Responder();
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Associated URL, used for debug output.
|
||||
std::string mURL;
|
||||
|
||||
@@ -216,6 +216,9 @@ class Responder : public AICurlResponderBufferEvents {
|
||||
// used only when printing debug output regarding activity of the Responder.
|
||||
void setURL(std::string const& url);
|
||||
|
||||
// Accessor.
|
||||
std::string const& getURL(void) const { return mURL; }
|
||||
|
||||
protected:
|
||||
// Called when the "HTTP/1.0 <status> <reason>" header is received.
|
||||
/*virual*/ void received_HTTP_header(void)
|
||||
@@ -237,7 +240,7 @@ class Responder : public AICurlResponderBufferEvents {
|
||||
completedHeaders(status, reason, mReceivedHeaders);
|
||||
}
|
||||
|
||||
// Derived classes can override this to get the HTML header that was received, when the message is completed.
|
||||
// Derived classes can override this to get the HTML headers that were received, when the message is completed.
|
||||
// The default does nothing.
|
||||
virtual void completedHeaders(U32 status, std::string const& reason, AIHTTPHeaders const& headers);
|
||||
|
||||
@@ -252,11 +255,6 @@ class Responder : public AICurlResponderBufferEvents {
|
||||
// The default is to interpret the content as LLSD and call completed().
|
||||
virtual void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer);
|
||||
|
||||
// Called from LLHTTPClient request calls, if an error occurs even before we can call one of the above.
|
||||
// It calls completed() with a fake status U32_MAX, as that is what some derived clients expect (bad design).
|
||||
// This means that if a derived class overrides completedRaw() it now STILL has to override completed() to catch this error.
|
||||
void fatalError(std::string const& reason);
|
||||
|
||||
// A derived class should return true if curl should follow redirections.
|
||||
// The default is not to follow redirections.
|
||||
virtual bool followRedir(void) { return false; }
|
||||
|
||||
@@ -366,7 +366,7 @@ class CurlEasyRequest : public CurlEasyHandle {
|
||||
private:
|
||||
curl_slist* mHeaders;
|
||||
AICurlEasyHandleEvents* mEventsTarget;
|
||||
CURLcode mResult;
|
||||
CURLcode mResult; //AIFIXME: this does not belong in the request object, but belongs in the response object.
|
||||
|
||||
AIHTTPTimeoutPolicy const* mTimeoutPolicy;
|
||||
std::string mLowercaseHostname; // Lowercase hostname (canonicalized) extracted from the url.
|
||||
|
||||
@@ -2105,7 +2105,7 @@ void CurlResponderBuffer::processOutput(AICurlEasyRequest_wat& curl_easy_request
|
||||
{
|
||||
// Only the responder registers for these events.
|
||||
llassert(mEventsTarget == mResponder.get());
|
||||
// Allow clients to parse headers before we attempt to parse
|
||||
// Allow clients to parse result codes and headers before we attempt to parse
|
||||
// the body and provide completed/result/error calls.
|
||||
mEventsTarget->completed_headers(responseCode, responseReason);
|
||||
}
|
||||
|
||||
@@ -393,7 +393,14 @@ LLBufferArray::segment_iterator_t LLBufferArray::splitAfter(U8* address)
|
||||
mSegments.insert(it, segment2);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//mMutexp should be locked before calling this.
|
||||
LLBufferArray::const_segment_iterator_t LLBufferArray::beginSegment() const
|
||||
{
|
||||
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
|
||||
return mSegments.begin();
|
||||
}
|
||||
|
||||
//mMutexp should be locked before calling this.
|
||||
LLBufferArray::segment_iterator_t LLBufferArray::beginSegment()
|
||||
{
|
||||
@@ -401,6 +408,13 @@ LLBufferArray::segment_iterator_t LLBufferArray::beginSegment()
|
||||
return mSegments.begin();
|
||||
}
|
||||
|
||||
//mMutexp should be locked before calling this.
|
||||
LLBufferArray::const_segment_iterator_t LLBufferArray::endSegment() const
|
||||
{
|
||||
ASSERT_LLBUFFERARRAY_MUTEX_LOCKED
|
||||
return mSegments.end();
|
||||
}
|
||||
|
||||
//mMutexp should be locked before calling this.
|
||||
LLBufferArray::segment_iterator_t LLBufferArray::endSegment()
|
||||
{
|
||||
|
||||
@@ -495,6 +495,7 @@ public:
|
||||
* @return Returns the segment if there is one.
|
||||
*/
|
||||
segment_iterator_t beginSegment();
|
||||
const_segment_iterator_t beginSegment() const;
|
||||
|
||||
/**
|
||||
* @brief Get the one-past-the-end segment in the buffer array
|
||||
@@ -502,6 +503,7 @@ public:
|
||||
* @return Returns the iterator for an invalid segment location.
|
||||
*/
|
||||
segment_iterator_t endSegment();
|
||||
const_segment_iterator_t endSegment() const;
|
||||
|
||||
/**
|
||||
* @brief Get the segment which holds the given address.
|
||||
|
||||
@@ -516,7 +516,7 @@ bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
||||
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.
|
||||
// to using this, causing the broken server to get confused.
|
||||
curlEasyRequest_w->addHeader("Expect:");
|
||||
curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, mBodySize);
|
||||
|
||||
@@ -77,6 +77,11 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
|
||||
*/
|
||||
LLURLRequest(ERequestAction action, std::string const& url, Injector* body, AICurlInterface::ResponderPtr responder, AIHTTPHeaders& headers, bool is_auth, bool no_compression);
|
||||
|
||||
protected:
|
||||
// Call abort(), not delete.
|
||||
/*virtual*/ ~LLURLRequest() { }
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Turn on cookie handling for this request with CURLOPT_COOKIEFILE.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user