Stellarium  0.16.1
List of all members | Public Member Functions | Friends
APIServiceResponse Struct Reference

Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod. More...

#include <RemoteControlServiceInterface.hpp>

Public Member Functions

 APIServiceResponse ()
 Constructs an invalid response. More...
 
void setHeader (const QByteArray &name, const QByteArray &val)
 Sets a specific HTTP header to the specified value. More...
 
void setHeader (const QByteArray &name, const int val)
 Shortcut for int header values. More...
 
void setCacheTime (int seconds)
 Sets the time in seconds for which the browser is allowed to cache the reply. More...
 
void setStatus (int status, const QByteArray &text)
 Sets the HTTP status type and status text. More...
 
void setData (const QByteArray &data)
 Replaces the current return data. More...
 
void appendData (const QByteArray &data)
 Appends to the current return data. More...
 
void writeRequestError (const QByteArray &msg)
 Sets the HTTP status to 400, and sets the response data to the message. More...
 
void writeJSON (const QJsonDocument &doc)
 Sets the Content-Type to "application/json" and serializes the given document into JSON text format. More...
 
void writeWrappedHTML (const QString &html, const QString &title)
 Because the HTML descriptions in Stellarium are often not compatible with "clean" HTML5 which is used for the main interface, this method can be used to explicitely wrap the given HTML snippet in a valid HTML 4.01 transitional document for better results, and include the stylesheet iframestyle.css for consistent styling when used in iframes of the RemoteControl web interface. More...
 
void writeFile (const QString &path, bool allowCaching=false)
 Writes the specified file contents into the response. More...
 

Friends

class APIController
 

Detailed Description

Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.

It contains the data that will be sent back to the client in the HTTP thread, when control returns to the APIController.

Definition at line 36 of file RemoteControlServiceInterface.hpp.

Constructor & Destructor Documentation

APIServiceResponse::APIServiceResponse ( )
inline

Constructs an invalid response.

Definition at line 40 of file RemoteControlServiceInterface.hpp.

Member Function Documentation

void APIServiceResponse::appendData ( const QByteArray &  data)
inline

Appends to the current return data.

Definition at line 75 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::setCacheTime ( int  seconds)
inline

Sets the time in seconds for which the browser is allowed to cache the reply.

Definition at line 57 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::setData ( const QByteArray &  data)
inline

Replaces the current return data.

Definition at line 70 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::setHeader ( const QByteArray &  name,
const QByteArray &  val 
)
inline

Sets a specific HTTP header to the specified value.

Definition at line 46 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::setHeader ( const QByteArray &  name,
const int  val 
)
inline

Shortcut for int header values.

Definition at line 51 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::setStatus ( int  status,
const QByteArray &  text 
)
inline

Sets the HTTP status type and status text.

Definition at line 63 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::writeFile ( const QString &  path,
bool  allowCaching = false 
)
inline

Writes the specified file contents into the response.

Parameters
pathThe (preferably absolute) path to a file
allowCachingif true, the browser is allowed to cache the file for one hour

Definition at line 122 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::writeJSON ( const QJsonDocument &  doc)
inline

Sets the Content-Type to "application/json" and serializes the given document into JSON text format.

Definition at line 88 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::writeRequestError ( const QByteArray &  msg)
inline

Sets the HTTP status to 400, and sets the response data to the message.

Definition at line 81 of file RemoteControlServiceInterface.hpp.

void APIServiceResponse::writeWrappedHTML ( const QString &  html,
const QString &  title 
)
inline

Because the HTML descriptions in Stellarium are often not compatible with "clean" HTML5 which is used for the main interface, this method can be used to explicitely wrap the given HTML snippet in a valid HTML 4.01 transitional document for better results, and include the stylesheet iframestyle.css for consistent styling when used in iframes of the RemoteControl web interface.

Parameters
htmlThe HTML snippet to wrap with HTML document tags
titleThe title of the page

Definition at line 109 of file RemoteControlServiceInterface.hpp.


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