LLURLRequest Class Reference

Class to handle url based requests. More...

#include <llurlrequest.h>

Inheritance diagram for LLURLRequest:

Inheritance graph
[legend]
Collaboration diagram for LLURLRequest:

Collaboration graph
[legend]

List of all members.

Public Types

enum  ERequestAction {
  INVALID, HTTP_HEAD, HTTP_GET, HTTP_PUT,
  HTTP_POST, HTTP_DELETE, HTTP_MOVE, REQUEST_ACTION_COUNT
}
 This enumeration is for specifying the type of request. More...

Public Member Functions

 LLURLRequest (ERequestAction action)
 Constructor.
 LLURLRequest (ERequestAction action, const std::string &url)
 Constructor.
virtual ~LLURLRequest ()
 Destructor.
void useProxy (bool use_proxy)
void useProxy (const std::string &proxy)
virtual EStatus handleError (EStatus status, LLPumpIO *pump)
 Give this pipe a chance to handle a generated error.
void setURL (const std::string &url)
 Set the url for the request.
void addHeader (const char *header)
 Add a header to the http post.
void checkRootCertificate (bool check)
 Check remote server certificate signed by a known root CA.
void setBodyLimit (U32 size)
 Return at most size bytes of body.
void setCallback (LLURLRequestComplete *callback)
 Set a completion callback for this URLRequest.

Protected Types

enum  EState { STATE_INITIALIZED, STATE_WAITING_FOR_RESPONSE, STATE_PROCESSING_RESPONSE, STATE_HAVE_RESPONSE }

Protected Member Functions

virtual EStatus process_impl (const LLChannelDescriptors &channels, buffer_ptr_t &buffer, bool &eos, LLSD &context, LLPumpIO *pump)
 Process the data in buffer.

Protected Attributes

EState mState
ERequestAction mAction
LLURLRequestDetailmDetail
LLIOPipe::ptr_t mCompletionCallback

Private Member Functions

 LOG_CLASS (LLURLRequest)
void initialize ()
 Initialize the object. Called during construction.
bool configure ()
 Handle action specific url request configuration.
 LLURLRequest (const LLURLRequest &)
 Declaration of unimplemented method to prevent copy construction.

Static Private Member Functions

static size_t downCallback (char *data, size_t size, size_t nmemb, void *user)
 Download callback method.
static size_t upCallback (char *data, size_t size, size_t nmemb, void *user)
 Upload callback method.


Detailed Description

Class to handle url based requests.

See also:
LLIOPipe
Currently, this class is implemented on top of curl. From the vantage of a programmer using this class, you do not care so much, but it's useful to know since in order to accomplish 'non-blocking' behavior, we have to use a more expensive curl interface which can still block if the server enters a half-accepted state. It would be worth the time and effort to eventually port this to a raw client socket.

Definition at line 64 of file llurlrequest.h.


Member Enumeration Documentation

This enumeration is for specifying the type of request.

Enumerator:
INVALID 
HTTP_HEAD 
HTTP_GET 
HTTP_PUT 
HTTP_POST 
HTTP_DELETE 
HTTP_MOVE 
REQUEST_ACTION_COUNT 

Definition at line 71 of file llurlrequest.h.

enum LLURLRequest::EState [protected]

Enumerator:
STATE_INITIALIZED 
STATE_WAITING_FOR_RESPONSE 
STATE_PROCESSING_RESPONSE 
STATE_HAVE_RESPONSE 

Definition at line 194 of file llurlrequest.h.


Constructor & Destructor Documentation

LLURLRequest::LLURLRequest ( LLURLRequest::ERequestAction  action  ) 

Constructor.

Parameters:
action One of the ERequestAction enumerations.
class LLURLRequest

Definition at line 99 of file llurlrequest.cpp.

References initialize(), and LLMemType::MTYPE_IO_URL_REQUEST.

Here is the call graph for this function:

LLURLRequest::LLURLRequest ( LLURLRequest::ERequestAction  action,
const std::string &  url 
)

Constructor.

Parameters:
action One of the ERequestAction enumerations.
url The url of the request. It should already be encoded.

Definition at line 106 of file llurlrequest.cpp.

References initialize(), LLMemType::MTYPE_IO_URL_REQUEST, and setURL().

Here is the call graph for this function:

LLURLRequest::~LLURLRequest (  )  [virtual]

Destructor.

Definition at line 116 of file llurlrequest.cpp.

References mDetail, and LLMemType::MTYPE_IO_URL_REQUEST.

LLURLRequest::LLURLRequest ( const LLURLRequest  )  [private]

Declaration of unimplemented method to prevent copy construction.


Member Function Documentation

LLURLRequest::LOG_CLASS ( LLURLRequest   )  [private]

void LLURLRequest::setURL ( const std::string &  url  ) 

Set the url for the request.

This method assumes the url is encoded appropriately for the request. The url must be set somehow before the first call to process(), or the url will not be set correctly.

Definition at line 122 of file llurlrequest.cpp.

References mDetail, LLMemType::MTYPE_IO_URL_REQUEST, and LLURLRequestDetail::mURL.

Referenced by LLXMLSDRPCClientFactory< Client >::build(), LLSDRPCClientFactory< Client >::build(), LLURLRequest(), and LLContextURLExtractor::process_impl().

Here is the caller graph for this function:

void LLURLRequest::addHeader ( const char *  header  ) 

Add a header to the http post.

The header must be correctly formatted for HTTP requests. This provides a raw interface if you know what kind of request you will be making during construction of this instance. All required headers will be automatically constructed, so this is usually useful for encoding parameters.

Definition at line 128 of file llurlrequest.cpp.

References LLURLRequestDetail::mCurlRequest, mDetail, LLMemType::MTYPE_IO_URL_REQUEST, and LLCurlEasyRequest::slist_append().

Referenced by LLXMLSDRPCClientFactory< Client >::build(), LLSDRPCClientFactory< Client >::build(), configure(), and request().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLURLRequest::checkRootCertificate ( bool  check  ) 

Check remote server certificate signed by a known root CA.

Set whether request will check that remote server certificates are signed by a known root CA when using HTTPS.

Definition at line 140 of file llurlrequest.cpp.

References FALSE, LLURLRequestDetail::mCurlRequest, mDetail, LLCurlEasyRequest::setopt(), LLCurlEasyRequest::setoptString(), and TRUE.

Referenced by request().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLURLRequest::setBodyLimit ( U32  size  ) 

Return at most size bytes of body.

If the body had more bytes than this limit, they will not be returned and the connection closed. In this case, STATUS_STOP will be passed to responseStatus();

Definition at line 134 of file llurlrequest.cpp.

References LLURLRequestDetail::mBodyLimit, mDetail, and LLURLRequestDetail::mIsBodyLimitSet.

void LLURLRequest::setCallback ( LLURLRequestComplete callback  ) 

Set a completion callback for this URLRequest.

The callback is added to this URLRequet's pump when either the entire buffer is known or an error like timeout or connection refused has happened. In the case of a complete transfer, this object builds a response chain such that the callback and the next process consumer get to read the output.

This setup is a little fragile since the url request consumer might not just read the data - it may do a channel change, which invalidates the input to the callback, but it works well in practice.

Definition at line 146 of file llurlrequest.cpp.

References headerCallback(), mCompletionCallback, LLURLRequestDetail::mCurlRequest, mDetail, LLMemType::MTYPE_IO_URL_REQUEST, and LLCurlEasyRequest::setHeaderCallback().

Referenced by request().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLURLRequest::useProxy ( bool  use_proxy  ) 

@ brief Turn off (or on) the CURLOPT_PROXY header.

Definition at line 160 of file llurlrequest.cpp.

References FALSE, lldebugs, llendl, LLURLRequestDetail::mCurlRequest, mDetail, NULL, LLCurlEasyRequest::setoptString(), and indra::ipc::saranwrap::status().

Referenced by request().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLURLRequest::useProxy ( const std::string &  proxy  ) 

@ brief Set the CURLOPT_PROXY header to the given value.

Definition at line 194 of file llurlrequest.cpp.

References LLURLRequestDetail::mCurlRequest, mDetail, and LLCurlEasyRequest::setoptString().

Here is the call graph for this function:

LLIOPipe::EStatus LLURLRequest::handleError ( LLIOPipe::EStatus  status,
LLPumpIO pump 
) [virtual]

Give this pipe a chance to handle a generated error.

Reimplemented from LLIOPipe.

Definition at line 200 of file llurlrequest.cpp.

References HTTP_STATUS_PIPE_ERROR, LLURLRequestComplete::httpStatus(), LLIOPipe::lookupStatusString(), mCompletionCallback, LLMemType::MTYPE_IO_URL_REQUEST, NULL, LLPumpIO::respond(), and LLURLRequestComplete::responseStatus().

Here is the call graph for this function:

LLIOPipe::EStatus LLURLRequest::process_impl ( const LLChannelDescriptors channels,
buffer_ptr_t buffer,
bool &  eos,
LLSD context,
LLPumpIO pump 
) [protected, virtual]

void LLURLRequest::initialize (  )  [private]

Initialize the object. Called during construction.

Definition at line 327 of file llurlrequest.cpp.

References downCallback(), LLURLRequestDetail::mCurlRequest, mDetail, mState, LLMemType::MTYPE_IO_URL_REQUEST, LLCurlEasyRequest::setopt(), LLCurlEasyRequest::setReadCallback(), LLCurlEasyRequest::setWriteCallback(), STATE_INITIALIZED, and upCallback().

Referenced by LLURLRequest().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLURLRequest::configure (  )  [private]

size_t LLURLRequest::downCallback ( char *  data,
size_t  size,
size_t  nmemb,
void *  user 
) [static, private]

size_t LLURLRequest::upCallback ( char *  data,
size_t  size,
size_t  nmemb,
void *  user 
) [static, private]

Upload callback method.

Definition at line 441 of file llurlrequest.cpp.

References LLBufferArray::countAfter(), LLChannelDescriptors::in(), llmin(), LLURLRequestDetail::mChannels, mDetail, LLURLRequestDetail::mLastRead, LLURLRequestDetail::mResponseBuffer, LLMemType::MTYPE_IO_URL_REQUEST, LLBufferArray::readAfter(), and S32.

Referenced by initialize().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 201 of file llurlrequest.h.

Referenced by downCallback(), initialize(), and process_impl().

Definition at line 202 of file llurlrequest.h.

Referenced by configure(), and process_impl().

Definition at line 204 of file llurlrequest.h.

Referenced by handleError(), process_impl(), and setCallback().


The documentation for this class was generated from the following files:

Generated on Fri May 16 09:20:46 2008 for SecondLife by  doxygen 1.5.5