TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Public Types | Signals | Public Member Functions | Properties | Private Slots | Private Member Functions | Static Private Member Functions | List of all members
QHttpRequest Class Reference

The class of the http request. More...

#include <qhttprequest.h>

+ Inheritance diagram for QHttpRequest:

Public Types

enum  HttpMethod {
  HTTP_DELETE = 0, HTTP_GET, HTTP_HEAD, HTTP_POST,
  HTTP_PUT, HTTP_CONNECT, HTTP_OPTIONS, HTTP_TRACE,
  HTTP_COPY, HTTP_LOCK, HTTP_MKCOL, HTTP_MOVE,
  HTTP_PROPFIND, HTTP_PROPPATCH, HTTP_SEARCH, HTTP_UNLOCK,
  HTTP_REPORT, HTTP_MKACTIVITY, HTTP_CHECKOUT, HTTP_MERGE,
  HTTP_MSEARCH, HTTP_NOTIFY, HTTP_SUBSCRIBE, HTTP_UNSUBSCRIBE,
  HTTP_PATCH, HTTP_PURGE
}
 Request method enumeration. More...
 

Signals

void data (const QByteArray &data)
 Emitted when new body data has been received. More...
 
void end ()
 Emitted when the request has been fully received. More...
 

Public Member Functions

HttpMethod method () const
 The method used for the request. More...
 
const QString methodString () const
 Returns the method string for the request. More...
 
const QUrl & url () const
 The complete URL for the request. More...
 
const QString path () const
 The path portion of the query URL. More...
 
const QString & httpVersion () const
 The HTTP version of the request. More...
 
const HeaderHashheaders () const
 Return all the headers sent by the client. More...
 
QString header (const QString &field)
 Get the value of a header. More...
 
const QString & remoteAddress () const
 IP Address of the client in dotted decimal format. More...
 
quint16 remotePort () const
 Outbound connection port for the client. More...
 
const QByteArray & body () const
 Request body data, empty for non POST/PUT requests. More...
 
bool successful () const
 If this request was successfully received. More...
 
void storeBody ()
 Utility function to make this request store all body data internally. More...
 

Properties

HeaderHash headers
 
QString remoteAddress
 
quint16 remotePort
 
QString method
 
QUrl url
 
QString path
 
QString httpVersion
 

Private Slots

void appendBody (const QByteArray &body)
 

Private Member Functions

 QHttpRequest (QHttpConnection *connection, QObject *parent=nullptr)
 
void setMethod (HttpMethod method)
 
void setVersion (const QString &version)
 
void setUrl (const QUrl &url)
 
void setHeaders (const HeaderHash headers)
 
void setSuccessful (bool success)
 
void setRemoteAddress (const QString &address)
 
void setRemotePort (quint16 port)
 

Static Private Member Functions

static QString MethodToString (HttpMethod method)
 

Detailed Description

The class of the http request.

Author
Greedysky greed.nosp@m.ysky.nosp@m.@163..nosp@m.com

Definition at line 32 of file qhttprequest.h.

Member Enumeration Documentation

Request method enumeration.

Note
Taken from http_parser.h – make sure to keep synced
Enumerator
HTTP_DELETE 
HTTP_GET 
HTTP_HEAD 
HTTP_POST 
HTTP_PUT 
HTTP_CONNECT 
HTTP_OPTIONS 
HTTP_TRACE 
HTTP_COPY 
HTTP_LOCK 
HTTP_MKCOL 
HTTP_MOVE 
HTTP_PROPFIND 
HTTP_PROPPATCH 
HTTP_SEARCH 
HTTP_UNLOCK 
HTTP_REPORT 
HTTP_MKACTIVITY 
HTTP_CHECKOUT 
HTTP_MERGE 
HTTP_MSEARCH 
HTTP_NOTIFY 
HTTP_SUBSCRIBE 
HTTP_UNSUBSCRIBE 
HTTP_PATCH 
HTTP_PURGE 

Definition at line 53 of file qhttprequest.h.

Constructor & Destructor Documentation

QHttpRequest::QHttpRequest ( QHttpConnection connection,
QObject *  parent = nullptr 
)
explicitprivate

Definition at line 34 of file qhttprequest.cpp.

References TTK_D, and TTK_INIT_PRIVATE.

Member Function Documentation

void QHttpRequest::appendBody ( const QByteArray &  body)
privateslot

Definition at line 118 of file qhttprequest.cpp.

References TTK_D.

Referenced by storeBody().

const QByteArray & QHttpRequest::body ( ) const

Request body data, empty for non POST/PUT requests.

See also
storeBody()

Definition at line 95 of file qhttprequest.cpp.

References TTK_D.

void QHttpRequest::data ( const QByteArray &  data)
signal

Emitted when new body data has been received.

Note
This may be emitted zero or more times depending on the request type.
Parameters
dataReceived data.

Referenced by QHttpConnectionPrivate::Body(), and storeBody().

void QHttpRequest::end ( )
signal

Emitted when the request has been fully received.

Note
The no more data() signals will be emitted after this.

Referenced by QHttpConnectionPrivate::invalidateRequest(), and QHttpConnectionPrivate::MessageComplete().

QString QHttpRequest::header ( const QString &  field)

Get the value of a header.

Headers are stored as lowercase so the input field will be lowercased.

Parameters
fieldName of the header field
Returns
Value of the header or empty string if not found.

Definition at line 42 of file qhttprequest.cpp.

References TTK_D.

const HeaderHash& QHttpRequest::headers ( ) const

Return all the headers sent by the client.

This returns a reference. If you want to store headers somewhere else, where the request may be deleted, make sure you store them as a copy.

Note
All header names are lowercase so that Content-Length becomes content-length etc.

Referenced by setHeaders().

const QString& QHttpRequest::httpVersion ( ) const

The HTTP version of the request.

Returns
A string in the form of "x.x"
HttpMethod QHttpRequest::method ( ) const

The method used for the request.

Referenced by methodString(), and setMethod().

const QString QHttpRequest::methodString ( ) const

Returns the method string for the request.

Note
This will plainly transform the enum into a string HTTP_GET -> "HTTP_GET".

Definition at line 72 of file qhttprequest.cpp.

References method(), and MethodToString().

QString QHttpRequest::MethodToString ( HttpMethod  method)
staticprivate

Definition at line 112 of file qhttprequest.cpp.

Referenced by methodString().

const QString QHttpRequest::path ( ) const

The path portion of the query URL.

See also
url()
const QString& QHttpRequest::remoteAddress ( ) const

IP Address of the client in dotted decimal format.

quint16 QHttpRequest::remotePort ( ) const

Outbound connection port for the client.

void QHttpRequest::setHeaders ( const HeaderHash  headers)
private

Definition at line 142 of file qhttprequest.cpp.

References headers(), and TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::setMethod ( HttpMethod  method)
private

Definition at line 124 of file qhttprequest.cpp.

References method(), and TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::setRemoteAddress ( const QString &  address)
private

Definition at line 154 of file qhttprequest.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::setRemotePort ( quint16  port)
private

Definition at line 160 of file qhttprequest.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::setSuccessful ( bool  success)
private

Definition at line 148 of file qhttprequest.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::MessageComplete().

void QHttpRequest::setUrl ( const QUrl &  url)
private

Definition at line 136 of file qhttprequest.cpp.

References TTK_D, and url().

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::setVersion ( const QString &  version)
private

Definition at line 130 of file qhttprequest.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpRequest::storeBody ( )

Utility function to make this request store all body data internally.

If you call this when the request is received via QHttpServer::newRequest() the request will take care of storing the body data for you. Once the end() signal is emitted you can access the body data with the body() function.

If you wish to handle incoming data yourself don't call this function and see the data() signal.

See also
data() body()

Definition at line 107 of file qhttprequest.cpp.

References appendBody(), and data().

bool QHttpRequest::successful ( ) const

If this request was successfully received.

Set before end() has been emitted, stating whether the message was properly received. This is false until the receiving the full request has completed.

Definition at line 101 of file qhttprequest.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::invalidateRequest().

const QUrl& QHttpRequest::url ( ) const

The complete URL for the request.

This includes the path and query string.

See also
path()

Referenced by setUrl().

Property Documentation

const HeaderHash & QHttpRequest::headers
read

Definition at line 35 of file qhttprequest.h.

const QString & QHttpRequest::httpVersion
read

Definition at line 41 of file qhttprequest.h.

QHttpRequest::HttpMethod QHttpRequest::method
read

Definition at line 38 of file qhttprequest.h.

const QString QHttpRequest::path
read

Definition at line 40 of file qhttprequest.h.

Referenced by QDlnaFileServer::handleRequest().

const QString & QHttpRequest::remoteAddress
read

Definition at line 36 of file qhttprequest.h.

quint16 QHttpRequest::remotePort
read

Definition at line 37 of file qhttprequest.h.

const QUrl & QHttpRequest::url
read

Definition at line 39 of file qhttprequest.h.


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