QtMockWebServer  1.0
 All Classes Functions Pages
Public Member Functions | List of all members
MockResponse Class Reference

The mock response to be sent to client. More...

#include <MockResponse.h>

Public Member Functions

 MockResponse ()
 An empty success response.
 
QString status () const
 Status line of response. More...
 
MockResponsesetResponseCode (int code)
 Set status code of response. More...
 
MockResponsesetStatus (const QString &status)
 Set status line of response. More...
 
QList< QString > headers () const
 A list of response header. More...
 
MockResponseclearHeaders ()
 Clear all response headers. More...
 
MockResponseaddHeader (const QString &header)
 Add a response header. More...
 
MockResponseaddHeader (const QString &key, const QString &value)
 Add a response header by key/value pairs. More...
 
MockResponsesetHeader (const QString &key, const QString &value)
 Set header value with given name. More...
 
MockResponseremoveHeader (const QString &key)
 Remove header with given name. More...
 
QByteArray body () const
 Body of response. More...
 
MockResponsesetBody (const QByteArray &body)
 Set body of response. More...
 
MockResponsesetChunkedBody (const QByteArray &body, int maxChunkSize)
 Set chunked body of response. More...
 

Detailed Description

The mock response to be sent to client.

Member Function Documentation

MockResponse & MockResponse::addHeader ( const QString &  header)

Add a response header.

Parameters
headerThe header to be added.
Returns
Reference of this object.
MockResponse & MockResponse::addHeader ( const QString &  key,
const QString &  value 
)

Add a response header by key/value pairs.

Parameters
keyHeader name.
valueHeader value.
Returns
Reference of this object.
QByteArray MockResponse::body ( ) const

Body of response.

Returns
Body of response.
MockResponse & MockResponse::clearHeaders ( )

Clear all response headers.

Returns
Reference of this object.
QList< QString > MockResponse::headers ( ) const

A list of response header.

Returns
A list of response of response headers.
MockResponse & MockResponse::removeHeader ( const QString &  key)

Remove header with given name.

Parameters
keyHeader name.
Returns
Reference of this object.
MockResponse & MockResponse::setBody ( const QByteArray &  body)

Set body of response.

Parameters
bodyBody of response.
Returns
Reference of this object.
MockResponse & MockResponse::setChunkedBody ( const QByteArray &  body,
int  maxChunkSize 
)

Set chunked body of response.

Parameters
bodyWhole body of response.
maxChunkSizeMax size limit of each chunk.
Returns
Reference of this object.
MockResponse & MockResponse::setHeader ( const QString &  key,
const QString &  value 
)

Set header value with given name.

Parameters
keyHeader name.
valueHeader value.
Returns
Reference of this object.
MockResponse & MockResponse::setResponseCode ( int  code)

Set status code of response.

Parameters
codeStatus code.
Returns
Reference of this object.
MockResponse & MockResponse::setStatus ( const QString &  status)

Set status line of response.

Parameters
statusStatus line.
Returns
Reference of this object.
QString MockResponse::status ( ) const

Status line of response.

Returns
Status line of response such as "HTTP/1.1 200 OK".

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