Add improved timeout handling for HTTP transactions.

Introduces AIHTTPTimeoutPolicy objects which do not just
specify a single "timeout" in seconds, but a plethora of
timings related to the life cycle of the average HTTP
transaction.

This knowledge is that moved to the Responder being
used instead of floating constants hardcoded in the
callers of http requests. This assumes that the same
timeout policy is wanted for each transaction that
uses the same Responder, which can be enforced is needed.

I added a AIHTTPTimeoutPolicy for EVERY responder,
only to make it easier later to tune timeout values
and/or to get feedback about which responder runs
into HTTP errors in debug output (especially time outs),
so that they can be tuned later. If we already understood
exactly what we were doing then most responders could
have been left alone and just return the default timeout
policy: by far most timeout policies are just a copy
of the default policy, currently.

This commit is not finished... It's a work in progress
(viewer runs fine with it though).
This commit is contained in:
Aleric Inglewood
2012-10-05 15:53:29 +02:00
parent 2766f17cb9
commit 3f1fb9a66e
67 changed files with 1654 additions and 198 deletions

View File

@@ -76,7 +76,7 @@ bool Request::getByteRange2(std::string const& url, AIHTTPHeaders const& headers
buffered_easy_request_w->addHeader(range.c_str());
}
buffered_easy_request_w->finalizeRequest(url);
buffered_easy_request_w->finalizeRequest(url, responder->getHTTPTimeoutPolicy(), buffered_easy_request);
}
buffered_easy_request->run();
@@ -84,7 +84,7 @@ bool Request::getByteRange2(std::string const& url, AIHTTPHeaders const& headers
return true; // We throw in case of problems.
}
bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::string const& data, ResponderPtr responder, S32 time_out)
bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::string const& data, ResponderPtr responder)
{
DoutEntering(dc::curl, "Request::post(" << url << ", ...)");
@@ -95,7 +95,7 @@ bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::s
AICurlEasyRequest_wat buffered_easy_request_w(*buffered_easy_request->mCurlEasyRequest);
AICurlResponderBuffer_wat buffer_w(*buffered_easy_request->mCurlEasyRequest);
buffer_w->prepRequest(buffered_easy_request_w, headers, responder, time_out);
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
U32 bytes = data.size();
bool success = buffer_w->getInput()->append(buffer_w->sChannels.out(), (U8 const*)data.data(), bytes);
@@ -106,7 +106,7 @@ bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::s
}
buffered_easy_request_w->setPost(bytes);
buffered_easy_request_w->addHeader("Content-Type: application/octet-stream");
buffered_easy_request_w->finalizeRequest(url);
buffered_easy_request_w->finalizeRequest(url, responder->getHTTPTimeoutPolicy(), buffered_easy_request);
}
buffered_easy_request->run();
@@ -114,7 +114,7 @@ bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::s
return true; // We throw in case of problems.
}
bool Request::post3(std::string const& url, AIHTTPHeaders const& headers, LLSD const& data, ResponderPtr responder, S32 time_out)
bool Request::post3(std::string const& url, AIHTTPHeaders const& headers, LLSD const& data, ResponderPtr responder)
{
DoutEntering(dc::curl, "Request::post(" << url << ", ...)");
@@ -125,7 +125,7 @@ bool Request::post3(std::string const& url, AIHTTPHeaders const& headers, LLSD c
AICurlEasyRequest_wat buffered_easy_request_w(*buffered_easy_request->mCurlEasyRequest);
AICurlResponderBuffer_wat buffer_w(*buffered_easy_request->mCurlEasyRequest);
buffer_w->prepRequest(buffered_easy_request_w, headers, responder, time_out);
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
LLBufferStream buffer_stream(buffer_w->sChannels, buffer_w->getInput().get());
LLSDSerialize::toXML(data, buffer_stream);
@@ -134,7 +134,7 @@ bool Request::post3(std::string const& url, AIHTTPHeaders const& headers, LLSD c
S32 bytes = buffer_w->getInput()->countAfter(buffer_w->sChannels.out(), NULL);
buffered_easy_request_w->setPost(bytes);
buffered_easy_request_w->addHeader("Content-Type: application/llsd+xml");
buffered_easy_request_w->finalizeRequest(url);
buffered_easy_request_w->finalizeRequest(url, responder->getHTTPTimeoutPolicy(), buffered_easy_request);
lldebugs << "POSTING: " << bytes << " bytes." << llendl;
}