More work in progress

This commit is contained in:
Aleric Inglewood
2012-07-31 22:23:52 +02:00
parent cdefc0e384
commit 29908533cd
7 changed files with 37 additions and 19 deletions

View File

@@ -1231,12 +1231,12 @@ size_t CurlResponderBuffer::curlWriteCallback(char* data, size_t size, size_t nm
// to make sure that callbacks and destruction aren't done simultaneously.
AICurlEasyRequest_wat buffered_easy_request_w(*lockobj);
S32 bytes = size * nmemb; // The amount to write.
AICurlResponderBuffer_wat buffer_w(*lockobj);
// CurlResponderBuffer::setBodyLimit is never called, so buffer_w->mBodyLimit is infinite.
//S32 bytes = llmin(size * nmemb, buffer_w->mBodyLimit); buffer_w->mBodyLimit -= bytes;
S32 bytes = size * nmemb;
buffer_w->getOutput()->append(sChannels.in(), (U8 const*)data, bytes);
mResponseTransferedBytes += bytes;
buffer_w->mResponseTransferedBytes += bytes; // Accumulate data received from the server.
return bytes;
}
@@ -1252,7 +1252,8 @@ size_t CurlResponderBuffer::curlReadCallback(char* data, size_t size, size_t nme
S32 bytes = size * nmemb; // The maximum amount to read.
AICurlResponderBuffer_wat buffer_w(*lockobj);
buffer_w->mLastRead = buffer_w->getInput()->readAfter(sChannels.out(), buffer_w->mLastRead, (U8*)data, bytes);
return bytes; // Return the amount actually read.
buffer_w->mRequestTransferedBytes += bytes; // Accumulate data sent to the server.
return bytes; // Return the amount actually read (might be lowered by readAfter()).
}
//static

View File

@@ -239,6 +239,10 @@ void AICurlEasyRequestStateMachine::finish_impl(void)
AICurlEasyRequestStateMachine::AICurlEasyRequestStateMachine(bool buffered) : mBuffered(buffered), mCurlEasyRequest(buffered)
{
Dout(dc::statemachine, "Calling AICurlEasyRequestStateMachine(" << (buffered ? "true" : "false") << ") [" << (void*)this << "] [" << (void*)mCurlEasyRequest.get() << "]");
if (!mBuffered)
{
llwarns << "Using unbuffered AICurlEasyRequestStateMachine" << llendl;
}
}
//static

View File

@@ -316,7 +316,7 @@ class CurlResponderBuffer : protected AICurlEasyHandleEvents {
LLIOPipe::buffer_ptr_t mOutput;
AICurlInterface::ResponderPtr mResponder;
//U32 mBodyLimit; // From the old LLURLRequestDetail::mBodyLimit, but never used.
S32 mByteAccumulator;
S32 mRequestTransferedBytes;
S32 mResponseTransferedBytes;
public:

View File

@@ -39,7 +39,11 @@
#endif
#include <deque>
// On linux, add -DDEBUG_WINDOWS_CODE_ON_LINUX to test the windows code used in this file.
#if !defined(DEBUG_WINDOWS_CODE_ON_LINUX) || !defined(LL_LINUX) || defined(LL_RELEASE)
#undef DEBUG_WINDOWS_CODE_ON_LINUX
#define DEBUG_WINDOWS_CODE_ON_LINUX 0
#endif
#if DEBUG_WINDOWS_CODE_ON_LINUX

View File

@@ -298,6 +298,7 @@ static void request(
}
//AIFIXME: req->setCallback(new LLHTTPClientURLAdaptor(responder));
llassert_always(false);
if (method == LLURLRequest::HTTP_POST && gMessageSystem)
{

View File

@@ -147,19 +147,12 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)
}
// This might throw AICurlNoEasyHandle.
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string const& url) : AICurlEasyRequestStateMachine(false), mAction(action), mURL(url)
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string const& url) : AICurlEasyRequestStateMachine(true), mAction(action), mURL(url)
{
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
{
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
//AIFIXME: we can't really use the other callbacks: they have to be extended... curlEasyRequest_w->setWriteCallback(&downCallback, (void*)this);
//AIFIXME: curlEasyRequest_w->setReadCallback(&upCallback, (void*)this);
}
//AIFIXME: stuff they have to be extended with... mRequestTransferedBytes = 0;
//AIFIXME: stuff they have to be extended with... mResponseTransferedBytes = 0;
//AIFIXME: start statemachine mState = STATE_INITIALIZED;
llassert_always(false);
}
#if 0
@@ -468,6 +461,13 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
}
#endif // AI_UNUSED
S32 LLURLRequest::bytes_to_send(void) const
{
//AIFIXME: how to get the number of bytes to send?
llassert_always(false);
return 0;
}
static LLFastTimer::DeclareTimer FTM_URL_REQUEST_CONFIGURE("URL Configure");
bool LLURLRequest::configure()
{
@@ -475,9 +475,6 @@ bool LLURLRequest::configure()
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
bool rv = false;
S32 bytes = mDetail->mResponseBuffer->countAfter(
mDetail->mChannels.in(),
NULL);
{
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
switch(mAction)
@@ -498,16 +495,19 @@ bool LLURLRequest::configure()
break;
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.
addHeader("Expect:");
S32 bytes = bytes_to_send();
curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, bytes);
rv = true;
break;
}
case HTTP_POST:
{
// Disable the expect http 1.1 extension. POST and PUT default
// to turning this on, and I am not too sure what it means.
addHeader("Expect:");
@@ -517,13 +517,14 @@ bool LLURLRequest::configure()
addHeader("Content-Type:");
// Set the handle for an http post
S32 bytes = bytes_to_send();
curlEasyRequest_w->setPost(NULL, bytes);
// Set Accept-Encoding to allow response compression
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
rv = true;
break;
}
case HTTP_DELETE:
// Set the handle for an http post
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE");
@@ -543,7 +544,7 @@ bool LLURLRequest::configure()
}
if(rv)
{
curlEasyRequest_w->finalizeRequest(mDetail->mURL);
curlEasyRequest_w->finalizeRequest(mURL);
}
}
return rv;

View File

@@ -97,6 +97,13 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
*/
bool configure(void);
/**
* @ brief Return the number of bytes to POST or PUT to the server.
*
* @return Returns the number of bytes we're about to upload.
*/
S32 bytes_to_send(void) const;
private:
ERequestAction mAction;
std::string mURL;