LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::CustomNetworkReply Class Reference

A network reply with customizable content and reply headers. More...

#include "customnetworkreply.h"

+ Inheritance diagram for LC::Util::CustomNetworkReply:
+ Collaboration diagram for LC::Util::CustomNetworkReply:

Public Member Functions

 CustomNetworkReply (const QUrl &url, QObject *parent=nullptr)
 Creates the reply with the given url and parent. 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 () override
 Reimplemented from QNetworkReply::abort(). More...
 
qint64 bytesAvailable () const override
 Reimplemented from QNetworkReply::bytesAvailable(). More...
 
bool isSequential () const override
 Reimplemented from QNetworkReply::isSequential(). More...
 

Protected Member Functions

qint64 readData (char *, qint64) override
 

Detailed Description

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 32 of file customnetworkreply.h.

Constructor & Destructor Documentation

◆ CustomNetworkReply()

LC::Util::CustomNetworkReply::CustomNetworkReply ( const QUrl &  url,
QObject *  parent = nullptr 
)
explicit

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()

Parameters
[in]urlThe URL this custom reply corresponds to.
[in]parentThe parent object of this object.

Definition at line 21 of file customnetworkreply.cpp.

Member Function Documentation

◆ abort()

void LC::Util::CustomNetworkReply::abort ( )
override

Reimplemented from QNetworkReply::abort().

This function does nothing.

Definition at line 54 of file customnetworkreply.cpp.

◆ bytesAvailable()

qint64 LC::Util::CustomNetworkReply::bytesAvailable ( ) const
override

Reimplemented from QNetworkReply::bytesAvailable().

This function returns the number of bytes left unread.

Definition at line 58 of file customnetworkreply.cpp.

Referenced by isSequential().

+ Here is the caller graph for this function:

◆ isSequential()

bool LC::Util::CustomNetworkReply::isSequential ( ) const
override

Reimplemented from QNetworkReply::isSequential().

This function always returns true.

Definition at line 63 of file customnetworkreply.cpp.

References bytesAvailable(), and LC::Util::oral::sph::min.

+ Here is the call graph for this function:

◆ readData()

qint64 LC::Util::CustomNetworkReply::readData ( char *  data,
qint64  maxSize 
)
overrideprotected

Definition at line 68 of file customnetworkreply.cpp.

◆ SetContent() [1/2]

void LC::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.

Parameters
[in]dataThe data this network reply should contain.

Definition at line 37 of file customnetworkreply.cpp.

◆ SetContent() [2/2]

void LC::Util::CustomNetworkReply::SetContent ( const QString &  string)

Sets content of this reply to the given string.

This convenience function is equivalent to

SetContent (string.toUtf8 ());
Parameters
[in]stringThe string to set.

Definition at line 32 of file customnetworkreply.cpp.

Referenced by SetContentType().

+ Here is the caller graph for this function:

◆ SetContentType()

void LC::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

SetHeader (QNetworkRequest::ContentType, type);

Definition at line 27 of file customnetworkreply.cpp.

References SetContent().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files:
LC::Util::CustomNetworkReply::SetContent
void SetContent(const QString &string)
Sets content of this reply to the given string.
Definition: customnetworkreply.cpp:32
LC::ContentType
ContentType
Definition: itexteditor.h:22