NuriaProject Framework  0.1
The NuriaProject Framework
Signals | Public Member Functions | List of all members
Nuria::HttpPostBodyReader Class Referenceabstract

Abstract class for readers of the body of HTTP POST requests. More...

#include <httppostbodyreader.hpp>

Inheritance diagram for Nuria::HttpPostBodyReader:
Nuria::HttpMultiPartReader Nuria::HttpUrlEncodedReader

Signals

void completed (bool success)
 
void fieldCompleted (const QString &fieldName)
 
void fieldFound (const QString &fieldName)
 

Public Member Functions

 HttpPostBodyReader (QObject *parent=0)
 
 ~HttpPostBodyReader ()
 
virtual qint64 fieldBytesTransferred (const QString &field) const =0
 
virtual qint64 fieldLength (const QString &field) const =0
 
virtual QString fieldMimeType (const QString &field) const =0
 
virtual QStringList fieldNames () const =0
 
virtual QIODevice * fieldStream (const QString &field)=0
 
virtual QByteArray fieldValue (const QString &field)
 
virtual bool hasFailed () const =0
 
virtual bool hasField (const QString &field) const
 
virtual bool isComplete () const =0
 
virtual bool isFieldComplete (const QString &field) const
 

Detailed Description

Abstract class for readers of the body of HTTP POST requests.

When a client sends a POST request, the body may be in various formats. This abstract class offers a abstraction layer around this, so implementations don't have to deal with the differences.

Implementations of this abstract class will most likely use a QIODevice as input. Please be aware that the device is thought to be sequential, thus large amounts of data may be copied.

Constructor & Destructor Documentation

Nuria::HttpPostBodyReader::HttpPostBodyReader ( QObject *  parent = 0)
explicit

Constructor.

Nuria::HttpPostBodyReader::~HttpPostBodyReader ( )

Destructor.

Member Function Documentation

void Nuria::HttpPostBodyReader::completed ( bool  success)
signal

Emitted when the body has been completely processed. If success is true, parsing was successful. Else it failed.

See also
isComplete
virtual qint64 Nuria::HttpPostBodyReader::fieldBytesTransferred ( const QString &  field) const
pure virtual

Returns the amount of bytes transferred of field.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

void Nuria::HttpPostBodyReader::fieldCompleted ( const QString &  fieldName)
signal

Emitted when a field called fieldName has been completely received.

void Nuria::HttpPostBodyReader::fieldFound ( const QString &  fieldName)
signal

Emitted when a field called fieldName has been started to be transferred. Information about it may not be complete yet.

virtual qint64 Nuria::HttpPostBodyReader::fieldLength ( const QString &  field) const
pure virtual

Returns the total length of field. If field is unknown or the length is unknown, returns -1.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual QString Nuria::HttpPostBodyReader::fieldMimeType ( const QString &  field) const
pure virtual

Returns the MIME-Type of field. If field does not exist or the MIME-Type is unknown, returns an empty string.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual QStringList Nuria::HttpPostBodyReader::fieldNames ( ) const
pure virtual

Returns the list of known field names.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual QIODevice* Nuria::HttpPostBodyReader::fieldStream ( const QString &  field)
pure virtual

Returns a QIODevice which reads contents from field in a streaming fashion. If field has not been found, nullptr is returned instead.

Note
The returned device is expected to be sequential. This means that returning random-access devices is ok, but not required.
There is only one device per field. Subsequent calls return the same device.

If field is a known field but is currently been transferred, then the returned stream will operate upon the already received data and new received data is put into it.

Note
Ownership of the device belongs to the reader.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual QByteArray Nuria::HttpPostBodyReader::fieldValue ( const QString &  field)
virtual

Returns the value of field. If the field has not been received completely yet or there's no field, then a empty QByteArray is returned.

Warning
If you're expecting large amount of data, use fieldStream() instead.

The default implementation uses infoStream() to obtain the device and read all of its content, if isFieldComplete() returns true.

Reimplemented in Nuria::HttpUrlEncodedReader.

virtual bool Nuria::HttpPostBodyReader::hasFailed ( ) const
pure virtual

Returns true if parsing has failed.

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual bool Nuria::HttpPostBodyReader::hasField ( const QString &  field) const
virtual

Returns true if field exists. The default implementation looks for field in the result of fieldNames().

Reimplemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual bool Nuria::HttpPostBodyReader::isComplete ( ) const
pure virtual

Returns true if the body has been read completely. Also returns true if parsing has failed.

See also
completed hasFailed

Implemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.

virtual bool Nuria::HttpPostBodyReader::isFieldComplete ( const QString &  field) const
virtual

Returns true if transfer of field is complete. If it is not, or if field does not exist, false is returned.

The default implementation compares the result of fieldLength() to the one of fieldBytesTransferred().

Reimplemented in Nuria::HttpMultiPartReader, and Nuria::HttpUrlEncodedReader.


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