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 | Public Slots | Signals | Private Slots | Private Member Functions | List of all members
QHttpResponse Class Reference

The class of the http response. More...

#include <qhttpresponse.h>

+ Inheritance diagram for QHttpResponse:

Public Types

enum  StatusCode {
  STATUS_CONTINUE = 100, STATUS_SWITCH_PROTOCOLS = 101, STATUS_OK = 200, STATUS_CREATED = 201,
  STATUS_ACCEPTED = 202, STATUS_NON_AUTHORITATIVE_INFORMATION = 203, STATUS_NO_CONTENT = 204, STATUS_RESET_CONTENT = 205,
  STATUS_PARTIAL_CONTENT = 206, STATUS_MULTIPLE_CHOICES = 300, STATUS_MOVED_PERMANENTLY = 301, STATUS_FOUND = 302,
  STATUS_SEE_OTHER = 303, STATUS_NOT_MODIFIED = 304, STATUS_USE_PROXY = 305, STATUS_TEMPORARY_REDIRECT = 307,
  STATUS_BAD_REQUEST = 400, STATUS_UNAUTHORIZED = 401, STATUS_PAYMENT_REQUIRED = 402, STATUS_FORBIDDEN = 403,
  STATUS_NOT_FOUND = 404, STATUS_METHOD_NOT_ALLOWED = 405, STATUS_NOT_ACCEPTABLE = 406, STATUS_PROXY_AUTHENTICATION_REQUIRED = 407,
  STATUS_REQUEST_TIMEOUT = 408, STATUS_CONFLICT = 409, STATUS_GONE = 410, STATUS_LENGTH_REQUIRED = 411,
  STATUS_PRECONDITION_FAILED = 412, STATUS_REQUEST_ENTITY_TOO_LARGE = 413, STATUS_REQUEST_URI_TOO_LONG = 414, STATUS_REQUEST_UNSUPPORTED_MEDIA_TYPE = 415,
  STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416, STATUS_EXPECTATION_FAILED = 417, STATUS_INTERNAL_SERVER_ERROR = 500, STATUS_NOT_IMPLEMENTED = 501,
  STATUS_BAD_GATEWAY = 502, STATUS_SERVICE_UNAVAILABLE = 503, STATUS_GATEWAY_TIMEOUT = 504, STATUS_HTTP_VERSION_NOT_SUPPORTED = 505
}
 HTTP status code. More...
 

Public Slots

void setHeader (const QString &field, const QString &value)
 Sets a response header field to value. More...
 
void writeHead (int statusCode)
 Writes the header section of the response using status as the response status code. More...
 
void writeHead (StatusCode statusCode)
 
void write (const QByteArray &data)
 Writes a block of data to the client. More...
 
void flush ()
 Flushes the written data to the client. More...
 
void waitForBytesWritten ()
 Waiting for bytes to be written. See QAbstractSocket::waitForBytesWritten in the Qt documentation. More...
 
void end (const QByteArray &data="")
 End/finish the response. More...
 

Signals

void allBytesWritten ()
 Emitted when all the data has been sent. More...
 
void done ()
 Emitted when the response is finished. More...
 

Private Slots

void connectionClosed ()
 

Private Member Functions

 QHttpResponse (QHttpConnection *connection)
 
void setKeepAlive (bool alive)
 
bool isLast () const
 

Detailed Description

The class of the http response.

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

Definition at line 29 of file qhttpresponse.h.

Member Enumeration Documentation

HTTP status code.

Enumerator
STATUS_CONTINUE 
STATUS_SWITCH_PROTOCOLS 
STATUS_OK 
STATUS_CREATED 
STATUS_ACCEPTED 
STATUS_NON_AUTHORITATIVE_INFORMATION 
STATUS_NO_CONTENT 
STATUS_RESET_CONTENT 
STATUS_PARTIAL_CONTENT 
STATUS_MULTIPLE_CHOICES 
STATUS_MOVED_PERMANENTLY 
STATUS_FOUND 
STATUS_SEE_OTHER 
STATUS_NOT_MODIFIED 
STATUS_USE_PROXY 
STATUS_TEMPORARY_REDIRECT 
STATUS_BAD_REQUEST 
STATUS_UNAUTHORIZED 
STATUS_PAYMENT_REQUIRED 
STATUS_FORBIDDEN 
STATUS_NOT_FOUND 
STATUS_METHOD_NOT_ALLOWED 
STATUS_NOT_ACCEPTABLE 
STATUS_PROXY_AUTHENTICATION_REQUIRED 
STATUS_REQUEST_TIMEOUT 
STATUS_CONFLICT 
STATUS_GONE 
STATUS_LENGTH_REQUIRED 
STATUS_PRECONDITION_FAILED 
STATUS_REQUEST_ENTITY_TOO_LARGE 
STATUS_REQUEST_URI_TOO_LONG 
STATUS_REQUEST_UNSUPPORTED_MEDIA_TYPE 
STATUS_REQUESTED_RANGE_NOT_SATISFIABLE 
STATUS_EXPECTATION_FAILED 
STATUS_INTERNAL_SERVER_ERROR 
STATUS_NOT_IMPLEMENTED 
STATUS_BAD_GATEWAY 
STATUS_SERVICE_UNAVAILABLE 
STATUS_GATEWAY_TIMEOUT 
STATUS_HTTP_VERSION_NOT_SUPPORTED 

Definition at line 34 of file qhttpresponse.h.

Constructor & Destructor Documentation

QHttpResponse::QHttpResponse ( QHttpConnection connection)
explicitprivate

Definition at line 198 of file qhttpresponse.cpp.

References allBytesWritten(), TTK_D, and TTK_INIT_PRIVATE.

Member Function Documentation

void QHttpResponse::allBytesWritten ( )
signal

Emitted when all the data has been sent.

This signal indicates that the underlaying socket has transmitted all of it's buffered data. It is possible to implement memory-efficient file transfers by calling write() for a block of data only after receiving this signal.

Referenced by QHttpResponse().

void QHttpResponse::connectionClosed ( )
privateslot

Definition at line 264 of file qhttpresponse.cpp.

References done(), and TTK_D.

void QHttpResponse::done ( )
signal

Emitted when the response is finished.

You should not interact with this object after done() has been emitted as the object has already been scheduled for deletion.

Referenced by connectionClosed(), and end().

void QHttpResponse::end ( const QByteArray &  data = "")
slot

End/finish the response.

Data will be flushed to the underlying socket and the connection itself will be closed if this is the last response.

This will emit done() and queue this object for deletion. For details see memorymanagement.

Parameters
dataOptional data to be written before finishing.
Todo:
End connection and delete ourselves. Is this a still valid note?

Definition at line 243 of file qhttpresponse.cpp.

References done(), TTK_D, and write().

Referenced by QDlnaFileServer::handleRequest().

void QHttpResponse::flush ( )
slot

Flushes the written data to the client.

Note
writeHead() must be called before this function.

Definition at line 231 of file qhttpresponse.cpp.

References TTK_D.

bool QHttpResponse::isLast ( ) const
private

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 278 of file qhttpresponse.cpp.

References TTK_D.

Referenced by QHttpConnection::responseDone().

void QHttpResponse::setHeader ( const QString &  field,
const QString &  value 
)
slot

Sets a response header field to value.

Note
You must call this with all your custom headers before calling writeHead(), write() or end().
Parameters
fieldHeader field to be set.
valueHeader value to be set.

Definition at line 207 of file qhttpresponse.cpp.

References TTK_D.

Referenced by QDlnaFileServer::handleRequest().

void QHttpResponse::setKeepAlive ( bool  alive)
private

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 272 of file qhttpresponse.cpp.

References TTK_D.

Referenced by QHttpConnectionPrivate::HeadersComplete().

void QHttpResponse::waitForBytesWritten ( )
slot

Waiting for bytes to be written. See QAbstractSocket::waitForBytesWritten in the Qt documentation.

Note
writeHead() must be called before this function.

Definition at line 237 of file qhttpresponse.cpp.

References TTK_D.

void QHttpResponse::write ( const QByteArray &  data)
slot

Writes a block of data to the client.

Note
writeHead() must be called before this function.

Definition at line 225 of file qhttpresponse.cpp.

References TTK_D.

Referenced by end().

void QHttpResponse::writeHead ( int  statusCode)
slot

Writes the header section of the response using status as the response status code.

Parameters
statusCodeStatus code for the response.
Note
Any headers should be set before invoking this function with setHeader().

Definition at line 213 of file qhttpresponse.cpp.

References TTK_D.

Referenced by QDlnaFileServer::handleRequest().

void QHttpResponse::writeHead ( StatusCode  statusCode)
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 219 of file qhttpresponse.cpp.

References TTK_D, and TTKStaticCast.


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