NuriaProject Framework  0.1
The NuriaProject Framework
Public Member Functions | List of all members
Nuria::HttpMultiPartReader Class Reference

Reader for HTTP multi-part formatted data. More...

#include <httpmultipartreader.hpp>

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

Public Member Functions

 HttpMultiPartReader (QIODevice *device, const QByteArray &boundary, QObject *parent=nullptr)
 
 ~HttpMultiPartReader ()
 
qint64 fieldBytesTransferred (const QString &field) const override
 
qint64 fieldLength (const QString &field) const override
 
QString fieldMimeType (const QString &field) const override
 
QStringList fieldNames () const override
 
QIODevice * fieldStream (const QString &field) override
 
bool hasFailed () const override
 
bool hasField (const QString &field) const override
 
bool isComplete () const override
 
bool isFieldComplete (const QString &field) const override
 
- Public Member Functions inherited from Nuria::HttpPostBodyReader
 HttpPostBodyReader (QObject *parent=0)
 
 ~HttpPostBodyReader ()
 
virtual QByteArray fieldValue (const QString &field)
 

Additional Inherited Members

- Signals inherited from Nuria::HttpPostBodyReader
void completed (bool success)
 
void fieldCompleted (const QString &fieldName)
 
void fieldFound (const QString &fieldName)
 

Detailed Description

Reader for HTTP multi-part formatted data.

HTTP User-agents use specific formats to transfer form-data to the server. One of these formats is 'multi-part'.

See also
HttpClient::hasReadablePostBody() HttpClient::postBodyReader()
Limitations
The format itself does not require clients to tell the server beforehand how much data a single field will contain. Same applies for the MIME-type.

For the user of this class this means, that:

Constructor & Destructor Documentation

Nuria::HttpMultiPartReader::HttpMultiPartReader ( QIODevice *  device,
const QByteArray &  boundary,
QObject *  parent = nullptr 
)

Creates a multi-part reader which acts upon device.

Nuria::HttpMultiPartReader::~HttpMultiPartReader ( )

Destructor.

Member Function Documentation

qint64 Nuria::HttpMultiPartReader::fieldBytesTransferred ( const QString &  field) const
overridevirtual

Returns the amount of bytes transferred of field.

Implements Nuria::HttpPostBodyReader.

qint64 Nuria::HttpMultiPartReader::fieldLength ( const QString &  field) const
overridevirtual

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

Implements Nuria::HttpPostBodyReader.

QString Nuria::HttpMultiPartReader::fieldMimeType ( const QString &  field) const
overridevirtual

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

Implements Nuria::HttpPostBodyReader.

QStringList Nuria::HttpMultiPartReader::fieldNames ( ) const
overridevirtual

Returns the list of known field names.

Implements Nuria::HttpPostBodyReader.

QIODevice* Nuria::HttpMultiPartReader::fieldStream ( const QString &  field)
overridevirtual

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.

Implements Nuria::HttpPostBodyReader.

bool Nuria::HttpMultiPartReader::hasFailed ( ) const
overridevirtual

Returns true if parsing has failed.

Implements Nuria::HttpPostBodyReader.

bool Nuria::HttpMultiPartReader::hasField ( const QString &  field) const
overridevirtual

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

Reimplemented from Nuria::HttpPostBodyReader.

bool Nuria::HttpMultiPartReader::isComplete ( ) const
overridevirtual

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

See also
completed hasFailed

Implements Nuria::HttpPostBodyReader.

bool Nuria::HttpMultiPartReader::isFieldComplete ( const QString &  field) const
overridevirtual

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 from Nuria::HttpPostBodyReader.


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