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

A filter can modify a HttpClients outgoing stream. More...

#include <httpfilter.hpp>

Inheritance diagram for Nuria::HttpFilter:

Public Member Functions

 HttpFilter (QObject *parent=0)
 
 ~HttpFilter () override
 
virtual QByteArray filterBegin (HttpClient *client)
 
virtual bool filterData (HttpClient *client, QByteArray &data)
 
virtual QByteArray filterEnd (HttpClient *client)
 
virtual bool filterHeaders (HttpClient *client, HttpClient::HeaderMap &headers)
 
virtual QByteArray filterName () const
 

Detailed Description

A filter can modify a HttpClients outgoing stream.

Filters allow you to modify the data a HttpClient sends back. This can be used to implement compression algorithms or on-the-fly "minifiers".

Warning
Filters are expected to be thread-safe.

Constructor & Destructor Documentation

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

Constructor.

Nuria::HttpFilter::~HttpFilter ( )
override

Destructor.

Member Function Documentation

virtual QByteArray Nuria::HttpFilter::filterBegin ( HttpClient client)
virtual

Called before the response body is sent. Implementations can return a QByteArray which, if not empty, will be sent to client. The default implementation returns an empty QByteArray.

virtual bool Nuria::HttpFilter::filterData ( HttpClient client,
QByteArray &  data 
)
virtual

Called before data is sent to the client. Implementations can modify data at will or even empty it. Returning false indicates an error and will instruct client to not send anything.

The default implementation returns true.

virtual QByteArray Nuria::HttpFilter::filterEnd ( HttpClient client)
virtual

Called after the response body has been sent. Implementations can return a QByteArray which will be sent to the remote client. The default implementation returns an empty QByteArray.

virtual bool Nuria::HttpFilter::filterHeaders ( HttpClient client,
HttpClient::HeaderMap headers 
)
virtual

Called before the HTTP header is sent by client. The implementation can change headers at will. Returning false indicates an error and will instruct client to not send anything.

Note
To add this filter to the "Transfer-Encoding" header automatically, see filterName().

The default implementation returns true.

virtual QByteArray Nuria::HttpFilter::filterName ( ) const
virtual

Returns the name of the filter. If the filter returns a non-empty QByteArray, it will only be triggered if the client mentions it in the "Accept-Encoding" HTTP header.

Also, if a non-empty QByteArray is returned, it will automatically be added to the "Content-Encoding" header upon sending.

Note
The correct header would be "Transfer-Encoding" for HTTP/1.1 requests, but the world doesn't care so we use "Content-Encoding" to be compliant with everyone else.

The default implementation returns an empty QByteArray.


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