![]() |
LeechCraft
0.6.70-10870-g558588d6ec
Modular cross-platform feature rich live environment.
|
A network reply with customizable content and reply headers. More...
#include "customnetworkreply.h"
Public Member Functions | |
CustomNetworkReply (const QUrl &url, QObject *parent=0) | |
Creates the reply with the given url and parent. More... | |
void | SetError (NetworkError error, const QString &reason=QString()) |
Sets the network error of this reply. More... | |
void | SetHeader (QNetworkRequest::KnownHeaders header, const QVariant &value) |
Sets the given header to the given value. More... | |
void | SetContentType (const QByteArray &type) |
Sets the content type of this reply. More... | |
void | SetContent (const QString &string) |
Sets content of this reply to the given string. More... | |
void | SetContent (const QByteArray &data) |
Sets content of this reply to the given data. More... | |
void | abort () |
Reimplemented from QNetworkReply::abort(). More... | |
qint64 | bytesAvailable () const |
Reimplemented from QNetworkReply::bytesAvailable(). More... | |
bool | isSequential () const |
Reimplemented from QNetworkReply::isSequential(). More... | |
Protected Member Functions | |
qint64 | readData (char *, qint64) |
A network reply with customizable content and reply headers.
This class provides a custom network reply with settable content and headers. It can be used, for example, in a plugin that renders local filesystem to QNetworkAccessManager-enabled plugins, or that just needs to provide a network reply with a predefined or runtime-generated string.
Definition at line 49 of file customnetworkreply.h.
LeechCraft::Util::CustomNetworkReply::CustomNetworkReply | ( | const QUrl & | url, |
QObject * | parent = 0 |
||
) |
Creates the reply with the given url and parent.
Sets the URL of this reply to be url. This URL will be returned by QNetworkReply::url()
[in] | url | The URL this custom reply corresponds to. |
[in] | parent | The parent object of this object. |
Definition at line 38 of file customnetworkreply.cpp.
void LeechCraft::Util::CustomNetworkReply::abort | ( | ) |
Reimplemented from QNetworkReply::abort().
This function does nothing.
Definition at line 81 of file customnetworkreply.cpp.
qint64 LeechCraft::Util::CustomNetworkReply::bytesAvailable | ( | ) | const |
Reimplemented from QNetworkReply::bytesAvailable().
This function returns the number of bytes left unread.
Definition at line 85 of file customnetworkreply.cpp.
Referenced by readData().
bool LeechCraft::Util::CustomNetworkReply::isSequential | ( | ) | const |
Reimplemented from QNetworkReply::isSequential().
This function always returns true
.
Definition at line 90 of file customnetworkreply.cpp.
|
protected |
Definition at line 95 of file customnetworkreply.cpp.
References bytesAvailable().
void LeechCraft::Util::CustomNetworkReply::SetContent | ( | const QString & | string | ) |
Sets content of this reply to the given string.
This convenience function is equivalent to
[in] | string | The string to set. |
Definition at line 59 of file customnetworkreply.cpp.
void LeechCraft::Util::CustomNetworkReply::SetContent | ( | const QByteArray & | data | ) |
Sets content of this reply to the given data.
This function sets the content of this reply to the given data, updates the Content-Length header and schedules emission of the readyRead()
and finished()
signals next time control reaches the event loop.
[in] | data | The data this network reply should contain. |
Definition at line 64 of file customnetworkreply.cpp.
References SetHeader().
void LeechCraft::Util::CustomNetworkReply::SetContentType | ( | const QByteArray & | type | ) |
Sets the content type of this reply.
This function sets the Content-Type header to type.
It is equivalent to
Definition at line 54 of file customnetworkreply.cpp.
void LeechCraft::Util::CustomNetworkReply::SetError | ( | NetworkError | error, |
const QString & | reason = QString () |
||
) |
Sets the network error of this reply.
This function can be used to set the given network error with an optional reason string.
[in] | error | The network error. |
[in] | reason | The additional reason string. |
Definition at line 44 of file customnetworkreply.cpp.
void LeechCraft::Util::CustomNetworkReply::SetHeader | ( | QNetworkRequest::KnownHeaders | header, |
const QVariant & | value | ||
) |
Sets the given header to the given value.
This function sets the given header to the given value.
[in] | header | The known standard header to set. |
[in] | value | The value of the header. |
Definition at line 49 of file customnetworkreply.cpp.
Referenced by SetContent().