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:
Aleric Inglewood
2012-10-20 23:48:30 +02:00
parent f8273e977e
commit 1e745ba48b
8 changed files with 31 additions and 18 deletions

View File

@@ -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);

View File

@@ -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; }

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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()
{

View File

@@ -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.

View File

@@ -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);

View File

@@ -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.
*/