SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | List of all members
qtwebapp::HttpRequestHandler Class Reference

#include <httprequesthandler.h>

+ Inheritance diagram for qtwebapp::HttpRequestHandler:

Public Member Functions

 HttpRequestHandler (QObject *parent=NULL)
 
virtual ~HttpRequestHandler ()
 
virtual void service (HttpRequest &request, HttpResponse &response)
 

Detailed Description

The request handler generates a response for each HTTP request. Web Applications usually have one central request handler that maps incoming requests to several controllers (servlets) based on the requested path.

You need to override the service() method or you will always get an HTTP error 501.

Warning
Be aware that the main request handler instance must be created on the heap and that it is used by multiple threads simultaneously.
See also
StaticFileController which delivers static local files.

Definition at line 29 of file httprequesthandler.h.

Constructor & Destructor Documentation

◆ HttpRequestHandler()

HttpRequestHandler::HttpRequestHandler ( QObject *  parent = NULL)

Constructor.

Parameters
parentParent object.

Definition at line 10 of file httprequesthandler.cpp.

11  : QObject(parent)
12 {}

◆ ~HttpRequestHandler()

HttpRequestHandler::~HttpRequestHandler ( )
virtual

Destructor

Definition at line 14 of file httprequesthandler.cpp.

15 {}

Member Function Documentation

◆ service()

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

Generate a response for an incoming HTTP request.

Parameters
requestThe received HTTP request
responseMust be used to return the response
Warning
This method must be thread safe

Reimplemented in qtwebapp::StaticFileController, and WebAPIRequestMapper.

Definition at line 17 of file httprequesthandler.cpp.

References qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getPath(), qtwebapp::HttpRequest::getVersion(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by qtwebapp::HttpConnectionHandler::read().

18 {
19  qCritical("HttpRequestHandler: you need to override the service() function");
20  qDebug("HttpRequestHandler: request=%s %s %s",request.getMethod().data(),request.getPath().data(),request.getVersion().data());
21  response.setStatus(501,"not implemented");
22  response.write("501 not implemented",true);
23 }
QByteArray getPath() const
QByteArray getVersion() const
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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