ofxHTTP
A collection of tools for HTTP.
ofx::HTTP::PutRequest Class Reference
Inheritance diagram for ofx::HTTP::PutRequest:
ofx::HTTP::FormRequest ofx::HTTP::Request

Public Member Functions

 PutRequest (const std::string &uri, const std::string &httpVersion=Poco::Net::HTTPMessage::HTTP_1_1)
 Construct a PutRequest with a given uri and http version. More...
 
void setPutFile (const std::string &filename)
 Set the file to include in the body of the PUT request. More...
 
void setPutBuffer (const ofBuffer &buffer)
 Set the buffer to include in the body of the PUT request. More...
 
void setContentRange (std::size_t startByte)
 Set the start byte to include in the header of the PUT request. More...
 
void setContentRange (std::size_t startByte, std::size_t endByte)
 Set the start byte to include in the header of the PUT request. More...
 
void setContentType (const std::string &contentType)
 Set the content type for the put request. More...
 
virtual void prepareRequest () override
 Prepare the current request.
 
virtual void writeRequestBody (std::ostream &requestStream) override
 Write the body of the request. More...
 
- Public Member Functions inherited from ofx::HTTP::FormRequest
virtual ~FormRequest ()
 Destroy this BaseReuqest.
 
void addFormField (const std::string &name, const std::string &value)
 Add a name value pair to upload with this request. More...
 
void setFormField (const std::string &name, const std::string &value)
 Set a name value pair to upload with this request. More...
 
void addFormFields (const Poco::Net::NameValueCollection &formFields)
 Add additional form fields. More...
 
void addFormFields (const std::multimap< std::string, std::string > &formFields)
 Add additional form fields. More...
 
void clearFormFields ()
 Clear all form fields.
 
- Public Member Functions inherited from ofx::HTTP::Request
 Request (const std::string &method, const std::string &uri, const std::string &httpVersion)
 Construct an Request. More...
 
virtual ~Request ()
 Destroy this Request.
 
virtual void write (std::ostream &ostr) const
 Write the HTTPRequest to an output stream. More...
 
void setRequestId (const std::string &requestId)
 Set the id of the request. More...
 
const std::string & getRequestId () const
 Get the id of the request. More...
 
const Poco::Net::HTMLForm & form () const
 Get a const reference to the raw form data. More...
 
int64_t estimatedContentLength () const
 Get the estimated content length for progress estimation purposes. More...
 

Protected Attributes

std::size_t _startByte
 
std::size_t _endByte
 
std::string _contentType
 
ofBuffer _buffer
 
- Protected Attributes inherited from ofx::HTTP::Request
std::string _requestId
 The original URI passed in during construction. More...
 
Poco::Net::HTMLForm _form
 A form with all query terms / form parameters. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ofx::HTTP::Request
static std::string generateId ()
 Generate a UUID string. More...
 
- Static Public Attributes inherited from ofx::HTTP::FormRequest
static const std::string DEFAULT_MEDIA_TYPE = "application/octet-stream"
 The default MIME type.
 

Constructor & Destructor Documentation

◆ PutRequest()

ofx::HTTP::PutRequest::PutRequest ( const std::string &  uri,
const std::string &  httpVersion = Poco::Net::HTTPMessage::HTTP_1_1 
)

Construct a PutRequest with a given uri and http version.

Parameters
urithe Put endpoint uri.
httpVersionEither HTTP/1.0 or HTTP/1.1.

Member Function Documentation

◆ setContentRange() [1/2]

void ofx::HTTP::PutRequest::setContentRange ( std::size_t  startByte)

Set the start byte to include in the header of the PUT request.

Parameters
startByteThe byte number representing the offset of the data included in the body. End byte is assumed to be the end of the resource.

◆ setContentRange() [2/2]

void ofx::HTTP::PutRequest::setContentRange ( std::size_t  startByte,
std::size_t  endByte 
)

Set the start byte to include in the header of the PUT request.

Parameters
startByteThe byte number representing the offset of the data included in the body.
endByteThe byte number representing the end offset of the data included in the body.
Exceptions
InvalidArgumentExceptionif startByte is not less than or equal to endByte.

◆ setContentType()

void ofx::HTTP::PutRequest::setContentType ( const std::string &  contentType)

Set the content type for the put request.

The default content type is application/octet-stream.

The content type of the PUT request.

◆ setPutBuffer()

void ofx::HTTP::PutRequest::setPutBuffer ( const ofBuffer &  buffer)

Set the buffer to include in the body of the PUT request.

Parameters
bufferThe buffer to include in the body of the PUT request.

◆ setPutFile()

void ofx::HTTP::PutRequest::setPutFile ( const std::string &  filename)

Set the file to include in the body of the PUT request.

Parameters
filenameThe file to include in the body of the PUT request.

◆ writeRequestBody()

void ofx::HTTP::PutRequest::writeRequestBody ( std::ostream &  requestStream)
overridevirtual

Write the body of the request.

Parameters
requestStreamThe stream to write to.

Reimplemented from ofx::HTTP::Request.


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