Stellarium 0.15.2
List of all members | Public Slots | Public Member Functions
RequestHandler Class Reference

This is the main request handler for the remote control plugin, receiving and dispatching the HTTP requests. More...

#include <RequestHandler.hpp>

+ Inheritance diagram for RequestHandler:
+ Collaboration diagram for RequestHandler:

Public Slots

void setUsePassword (bool v)
 Sets wether a password set with setPassword() is required by all requests. More...
 
bool getUsePassword ()
 Returns if a password is required to access the remote control. More...
 
void setPassword (const QString &pw)
 

Public Member Functions

 RequestHandler (const StaticFileControllerSettings &settings, QObject *parent=0)
 Constructs the request handler. More...
 
virtual ~RequestHandler ()
 The internal APIController, and all registered services are deleted. More...
 
void update (double deltaTime)
 Called in the main thread each frame, only passed on to APIController::update. More...
 
virtual void service (HttpRequest &request, HttpResponse &response)
 Receives the HttpRequest from the HttpListener. More...
 
- Public Member Functions inherited from HttpRequestHandler
 HttpRequestHandler (QObject *parent=NULL)
 Constructor. More...
 
virtual ~HttpRequestHandler ()
 Destructor. More...
 

Detailed Description

This is the main request handler for the remote control plugin, receiving and dispatching the HTTP requests.

It also handles the optional simple HTTP authentication. See service to find out how the requests are processed.

Definition at line 32 of file RequestHandler.hpp.

Constructor & Destructor Documentation

RequestHandler::RequestHandler ( const StaticFileControllerSettings settings,
QObject *  parent = 0 
)

Constructs the request handler.

This also creates an StaticFileController for the webroot folder, and an APIController.

To see the default services that are registered here, see API reference.

virtual RequestHandler::~RequestHandler ( )
virtual

The internal APIController, and all registered services are deleted.

Member Function Documentation

bool RequestHandler::getUsePassword ( )
inlineslot

Returns if a password is required to access the remote control.

Warning
Make sure to only call this only when the server is offline because they are not synchronized

Definition at line 68 of file RequestHandler.hpp.

virtual void RequestHandler::service ( HttpRequest request,
HttpResponse response 
)
virtual

Receives the HttpRequest from the HttpListener.

It checks the optional HTTP authentication and sets the keep-alive header if requested by the client.

If the authentication is correct, the request is processed according to the following rules:

  • If the request path starts with the string "/api/", then the request is passed to the APIController without further processing.
  • If a file specified in the special translate_files file is requested, the cached translated version of this file is returned. This cache is updated each time the app language changes.
  • Otherwise, it is passed to a StaticFileController that has been set up for the data/webroot folder.
Note
This method runs in an HTTP worker thread, not in the Stellarium main thread, so take caution.

Reimplemented from HttpRequestHandler.

void RequestHandler::setPassword ( const QString &  pw)
slot
Warning
Make sure to only call this only when the server is offline because they are not synchronized
void RequestHandler::setUsePassword ( bool  v)
slot

Sets wether a password set with setPassword() is required by all requests.

It uses HTTP Basic authorization, with an empty username.

Warning
Make sure to only call this only when the server is offline because they are not synchronized
void RequestHandler::update ( double  deltaTime)

Called in the main thread each frame, only passed on to APIController::update.


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