Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
IHTTPRequestHandler Class Referenceabstract

#include <IHTTPRequestHandler.h>

Inheritance diagram for IHTTPRequestHandler:
CHTTPFileHandler CHTTPImageTransformationHandler CHTTPJsonRpcHandler CHTTPPythonHandler CHTTPWebinterfaceAddonsHandler CHTTPImageHandler CHTTPVfsHandler CHTTPWebinterfaceHandler

Public Member Functions

virtual ~IHTTPRequestHandler ()=default
 
virtual IHTTPRequestHandlerCreate (const HTTPRequest &request) const =0
 Creates a new HTTP request handler for the given request.
 
virtual int GetPriority () const
 Returns the priority of the HTTP request handler.
 
virtual bool CanHandleRequest (const HTTPRequest &request) const =0
 Checks if the HTTP request handler can handle the given request.
 
virtual MHD_RESULT HandleRequest ()=0
 Handles the HTTP request.
 
virtual bool CanHandleRanges () const
 Whether the HTTP response could also be provided in ranges.
 
virtual bool CanBeCached () const
 Whether the HTTP response can be cached.
 
virtual int GetMaximumAgeForCaching () const
 Returns the maximum age (in seconds) for which the response can be cached.
 
virtual bool GetLastModifiedDate (CDateTime &lastModified) const
 Returns the last modification date of the response data.
 
virtual HttpResponseRanges GetResponseData () const
 Returns the ranges with raw data belonging to the response.
 
virtual std::string GetRedirectUrl () const
 Returns the URL to which the request should be redirected.
 
virtual std::string GetResponseFile () const
 Returns the path to the file that should be returned as the response.
 
const HTTPRequestGetRequest () const
 Returns the HTTP request handled by the HTTP request handler.
 
bool IsRequestRanged () const
 Returns true if the HTTP request is ranged, otherwise false.
 
void SetRequestRanged (bool ranged)
 Sets whether the HTTP request contains ranges or not.
 
void SetResponseStatus (int status)
 Sets the response status of the HTTP response.
 
bool HasResponseHeader (const std::string &field) const
 Checks if the given HTTP header field is part of the response details.
 
bool AddResponseHeader (const std::string &field, const std::string &value, bool allowMultiple=false)
 Adds the given HTTP header field and value to the response details.
 
const HTTPResponseDetailsGetResponseDetails () const
 Returns the HTTP response header details.
 
void AddPostField (const std::string &key, const std::string &value)
 Adds the given key-value pair extracted from the HTTP POST data.
 
bool AddPostData (const char *data, size_t size)
 Adds the given raw HTTP POST data.
 

Protected Member Functions

 IHTTPRequestHandler ()
 
 IHTTPRequestHandler (const HTTPRequest &request)
 
virtual bool appendPostData (const char *data, size_t size)
 
bool GetRequestedRanges (uint64_t totalLength)
 
bool GetHostnameAndPort (std::string &hostname, uint16_t &port)
 

Protected Attributes

HTTPRequest m_request
 
HTTPResponseDetails m_response
 
std::map< std::string, std::string > m_postFields
 

Constructor & Destructor Documentation

◆ ~IHTTPRequestHandler()

virtual IHTTPRequestHandler::~IHTTPRequestHandler ( )
virtualdefault

◆ IHTTPRequestHandler() [1/2]

IHTTPRequestHandler::IHTTPRequestHandler ( )
protected

◆ IHTTPRequestHandler() [2/2]

IHTTPRequestHandler::IHTTPRequestHandler ( const HTTPRequest & request)
explicitprotected

Member Function Documentation

◆ AddPostData()

bool IHTTPRequestHandler::AddPostData ( const char * data,
size_t size )

Adds the given raw HTTP POST data.

Parameters
dataRaw HTTP POST data
sizeSize of the raw HTTP POST data

◆ AddPostField()

void IHTTPRequestHandler::AddPostField ( const std::string & key,
const std::string & value )

Adds the given key-value pair extracted from the HTTP POST data.

Parameters
keyKey of the HTTP POST field
valueValue of the HTTP POST field

◆ AddResponseHeader()

bool IHTTPRequestHandler::AddResponseHeader ( const std::string & field,
const std::string & value,
bool allowMultiple = false )

Adds the given HTTP header field and value to the response details.

Parameters
fieldHTTP header field name
valueHTTP header field value
allowMultipleWhether the same header is allowed multiple times
Returns
True if the header field was added, otherwise false.

◆ appendPostData()

virtual bool IHTTPRequestHandler::appendPostData ( const char * data,
size_t size )
inlineprotectedvirtual

Reimplemented in CHTTPJsonRpcHandler, and CHTTPPythonHandler.

◆ CanBeCached()

virtual bool IHTTPRequestHandler::CanBeCached ( ) const
inlinevirtual

Whether the HTTP response can be cached.

Reimplemented in CHTTPFileHandler, CHTTPImageTransformationHandler, and CHTTPPythonHandler.

◆ CanHandleRanges()

virtual bool IHTTPRequestHandler::CanHandleRanges ( ) const
inlinevirtual

Whether the HTTP response could also be provided in ranges.

Reimplemented in CHTTPFileHandler, CHTTPImageTransformationHandler, and CHTTPPythonHandler.

◆ CanHandleRequest()

virtual bool IHTTPRequestHandler::CanHandleRequest ( const HTTPRequest & request) const
pure virtual

Checks if the HTTP request handler can handle the given request.

Parameters
requestHTTP request to be handled
Returns
True if the given HTTP request can be handled otherwise false.

Implemented in CHTTPImageHandler, CHTTPImageTransformationHandler, CHTTPJsonRpcHandler, CHTTPPythonHandler, CHTTPVfsHandler, CHTTPWebinterfaceAddonsHandler, and CHTTPWebinterfaceHandler.

◆ Create()

virtual IHTTPRequestHandler * IHTTPRequestHandler::Create ( const HTTPRequest & request) const
pure virtual

Creates a new HTTP request handler for the given request.

This call is responsible for doing some preparation work like - depending on the supported features - determining whether the requested entity supports ranges, whether it can be cached and what it's last modified date is.

Parameters
requestHTTP request to be handled

Implemented in CHTTPImageHandler, CHTTPImageTransformationHandler, CHTTPJsonRpcHandler, CHTTPPythonHandler, CHTTPVfsHandler, CHTTPWebinterfaceAddonsHandler, and CHTTPWebinterfaceHandler.

◆ GetHostnameAndPort()

bool IHTTPRequestHandler::GetHostnameAndPort ( std::string & hostname,
uint16_t & port )
protected

◆ GetLastModifiedDate()

virtual bool IHTTPRequestHandler::GetLastModifiedDate ( CDateTime & lastModified) const
inlinevirtual

Returns the last modification date of the response data.

This is only used if the response can be cached.

Reimplemented in CHTTPFileHandler, CHTTPImageTransformationHandler, and CHTTPPythonHandler.

◆ GetMaximumAgeForCaching()

virtual int IHTTPRequestHandler::GetMaximumAgeForCaching ( ) const
inlinevirtual

Returns the maximum age (in seconds) for which the response can be cached.

This is only used if the response can be cached.

Reimplemented in CHTTPImageHandler.

◆ GetPriority()

virtual int IHTTPRequestHandler::GetPriority ( ) const
inlinevirtual

Returns the priority of the HTTP request handler.

The higher the priority the more important is the HTTP request handler.

Reimplemented in CHTTPImageHandler, CHTTPImageTransformationHandler, CHTTPJsonRpcHandler, CHTTPPythonHandler, CHTTPVfsHandler, and CHTTPWebinterfaceAddonsHandler.

◆ GetRedirectUrl()

virtual std::string IHTTPRequestHandler::GetRedirectUrl ( ) const
inlinevirtual

Returns the URL to which the request should be redirected.

This is only used if the response type is HTTPRedirect.

Reimplemented in CHTTPFileHandler, and CHTTPPythonHandler.

◆ GetRequest()

const HTTPRequest & IHTTPRequestHandler::GetRequest ( ) const
inline

Returns the HTTP request handled by the HTTP request handler.

◆ GetRequestedRanges()

bool IHTTPRequestHandler::GetRequestedRanges ( uint64_t totalLength)
protected

◆ GetResponseData()

virtual HttpResponseRanges IHTTPRequestHandler::GetResponseData ( ) const
inlinevirtual

Returns the ranges with raw data belonging to the response.

This is only used if the response type is one of the HTTPMemoryDownload types.

Reimplemented in CHTTPImageTransformationHandler, CHTTPJsonRpcHandler, CHTTPPythonHandler, and CHTTPWebinterfaceAddonsHandler.

◆ GetResponseDetails()

const HTTPResponseDetails & IHTTPRequestHandler::GetResponseDetails ( ) const
inline

Returns the HTTP response header details.

◆ GetResponseFile()

virtual std::string IHTTPRequestHandler::GetResponseFile ( ) const
inlinevirtual

Returns the path to the file that should be returned as the response.

This is only used if the response type is HTTPFileDownload.

Reimplemented in CHTTPFileHandler.

◆ HandleRequest()

virtual MHD_RESULT IHTTPRequestHandler::HandleRequest ( )
pure virtual

Handles the HTTP request.

Returns
MHD_NO if a severe error has occurred otherwise MHD_YES.

Implemented in CHTTPFileHandler, CHTTPImageTransformationHandler, CHTTPJsonRpcHandler, CHTTPPythonHandler, and CHTTPWebinterfaceAddonsHandler.

◆ HasResponseHeader()

bool IHTTPRequestHandler::HasResponseHeader ( const std::string & field) const

Checks if the given HTTP header field is part of the response details.

Parameters
fieldHTTP header field name
Returns
True if the header field is set, otherwise false.

◆ IsRequestRanged()

bool IHTTPRequestHandler::IsRequestRanged ( ) const
inline

Returns true if the HTTP request is ranged, otherwise false.

◆ SetRequestRanged()

void IHTTPRequestHandler::SetRequestRanged ( bool ranged)
inline

Sets whether the HTTP request contains ranges or not.

◆ SetResponseStatus()

void IHTTPRequestHandler::SetResponseStatus ( int status)
inline

Sets the response status of the HTTP response.

Parameters
statusHTTP status of the response

Member Data Documentation

◆ m_postFields

std::map<std::string, std::string> IHTTPRequestHandler::m_postFields
protected

◆ m_request

HTTPRequest IHTTPRequestHandler::m_request
protected

◆ m_response

HTTPResponseDetails IHTTPRequestHandler::m_response
protected

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