Loading...
Searching...
No Matches
hueplusplus::IHttpHandler Class Referenceabstract

Abstract class for classes that handle http requests and multicast requests. More...

`#include <hueplusplus/IHttpHandler.h>`

Inheritance diagram for hueplusplus::IHttpHandler:
[legend]

## Public Member Functions

virtual | ~IHttpHandler ()=default
| Virtual dtor.
virtual std::string | send (const std::string &msg, const std::string &adr, int port=80) const =0
| Send a message to a specified host and return the response.
virtual std::string | sendGetHTTPBody (const std::string &msg, const std::string &adr, int port=80) const =0
| Send a message to a specified host and return the body of the response.
virtual std::vector< std::string > | sendMulticast (const std::string &msg, const std::string &adr="239.255.255.250", int port=1900, std::chrono::steady_clock::duration timeout=std::chrono::seconds(5)) const =0
| Send a multicast request with a specified message.
virtual std::string | sendHTTPRequest (const std::string &method, const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
| Send a HTTP request with the given method to the specified host and return the body of the response.
virtual std::string | GETString (const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
| Send a HTTP GET request to the specified host and return the body of the response.
virtual std::string | POSTString (const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
| Send a HTTP POST request to the specified host and return the body of the response.
virtual std::string | PUTString (const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
| Send a HTTP PUT request to the specified host and return the body of the response.
virtual std::string | DELETEString (const std::string &uri, const std::string &contentType, const std::string &body, const std::string &adr, int port=80) const =0
| Send a HTTP DELETE request to the specified host and return the body of the response.
virtual nlohmann::json | GETJson (const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
| Send a HTTP GET request to the specified host and return the body of the response parsed as JSON.
virtual nlohmann::json | POSTJson (const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
| Send a HTTP POST request to the specified host and return the body of the response parsed as JSON.
virtual nlohmann::json | PUTJson (const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
| Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON.
virtual nlohmann::json | DELETEJson (const std::string &uri, const nlohmann::json &body, const std::string &adr, int port=80) const =0
| Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON.

## Detailed Description

Abstract class for classes that handle http requests and multicast requests.

## Constructor & Destructor Documentation

## ~IHttpHandler()

virtual hueplusplus::IHttpHandler::~IHttpHandler | ( |  | ) |

virtual default

Virtual dtor.

## Member Function Documentation

## DELETEJson()

virtual nlohmann::json hueplusplus::IHttpHandler::DELETEJson | ( | const std::string & | uri,
|  | const nlohmann::json & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON.

Parameters

  uri | Uniform Resource Identifier in the request
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  Parsed body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  nlohmann::json::parse_error | when the body could not be parsed

Implemented in hueplusplus::BaseHttpHandler.

## DELETEString()

virtual std::string hueplusplus::IHttpHandler::DELETEString | ( | const std::string & | uri,
|  | const std::string & | contentType,
|  | const std::string & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP DELETE request to the specified host and return the body of the response.

Parameters

  uri | Uniform Resource Identifier in the request
  contentType | MIME type of the body data e.g. "text/html", "application/json", ...
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80 that specifies the port to which the request is sent to. Default is 80

Returns
  Body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## GETJson()

virtual nlohmann::json hueplusplus::IHttpHandler::GETJson | ( | const std::string & | uri,
|  | const nlohmann::json & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP GET request to the specified host and return the body of the response parsed as JSON.

Parameters

  uri | Uniform Resource Identifier in the request
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  Parsed body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  nlohmann::json::parse_error | when the body could not be parsed

Implemented in hueplusplus::BaseHttpHandler.

## GETString()

virtual std::string hueplusplus::IHttpHandler::GETString | ( | const std::string & | uri,
|  | const std::string & | contentType,
|  | const std::string & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP GET request to the specified host and return the body of the response.

Parameters

  uri | Uniform Resource Identifier in the request
  contentType | MIME type of the body data e.g. "text/html", "application/json", ...
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80 that specifies the port to which the request is sent to. Default is 80

Returns
  Body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## POSTJson()

virtual nlohmann::json hueplusplus::IHttpHandler::POSTJson | ( | const std::string & | uri,
|  | const nlohmann::json & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP POST request to the specified host and return the body of the response parsed as JSON.

Parameters

  uri | Uniform Resource Identifier in the request
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  Parsed body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  nlohmann::json::parse_error | when the body could not be parsed

Implemented in hueplusplus::BaseHttpHandler.

## POSTString()

virtual std::string hueplusplus::IHttpHandler::POSTString | ( | const std::string & | uri,
|  | const std::string & | contentType,
|  | const std::string & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP POST request to the specified host and return the body of the response.

Parameters

  uri | Uniform Resource Identifier in the request
  contentType | MIME type of the body data e.g. "text/html", "application/json", ...
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80 that specifies the port to which the request is sent to. Default is 80

Returns
  Body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## PUTJson()

virtual nlohmann::json hueplusplus::IHttpHandler::PUTJson | ( | const std::string & | uri,
|  | const nlohmann::json & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON.

Parameters

  uri | Uniform Resource Identifier in the request
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  Parsed body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body
  nlohmann::json::parse_error | when the body could not be parsed

Implemented in hueplusplus::BaseHttpHandler.

## PUTString()

virtual std::string hueplusplus::IHttpHandler::PUTString | ( | const std::string & | uri,
|  | const std::string & | contentType,
|  | const std::string & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP PUT request to the specified host and return the body of the response.

Parameters

  uri | Uniform Resource Identifier in the request
  contentType | MIME type of the body data e.g. "text/html", "application/json", ...
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80 that specifies the port to which the request is sent to. Default is 80

Returns
  Body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## send()

virtual std::string hueplusplus::IHttpHandler::send | ( | const std::string & | msg,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a message to a specified host and return the response.

Parameters

  msg | The message that should be sent to the specified address
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  The response of the host as a string

Exceptions

  std::system_error | when system or socket operations fail

Implemented in hueplusplus::LinHttpHandler, and hueplusplus::WinHttpHandler.

## sendGetHTTPBody()

virtual std::string hueplusplus::IHttpHandler::sendGetHTTPBody | ( | const std::string & | msg,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a message to a specified host and return the body of the response.

Parameters

  msg | The message that should sent to the specified address
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  The body of the response of the host as a string

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## sendHTTPRequest()

virtual std::string hueplusplus::IHttpHandler::sendHTTPRequest | ( | const std::string & | method,
|  | const std::string & | uri,
|  | const std::string & | contentType,
|  | const std::string & | body,
|  | const std::string & | adr,
|  | int | port = 80 ) const

pure virtual

Send a HTTP request with the given method to the specified host and return the body of the response.

Parameters

  method | HTTP method type e.g. GET, HEAD, POST, PUT, DELETE, ...
  uri | Uniform Resource Identifier in the request
  contentType | MIME type of the body data e.g. "text/html", "application/json", ...
  body | Request body, may be empty
  adr | Ip or hostname in dotted decimal notation like "192.168.2.1"
  port | Optional port the request is sent to, default is 80

Returns
  Body of the response of the host

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body

Implemented in hueplusplus::BaseHttpHandler.

## sendMulticast()

virtual std::vector< std::string > hueplusplus::IHttpHandler::sendMulticast | ( | const std::string & | msg,
|  | const std::string & | adr = "239.255.255.250",
|  | int | port = 1900,
|  | std::chrono::steady_clock::duration | timeout = std::chrono::seconds(5) ) const

pure virtual

Send a multicast request with a specified message.

Parameters

  msg | The message that should sent to the specified multicast address
  adr | Optional ip or hostname in dotted decimal notation, default is "239.255.255.250"
  port | Optional port the request is sent to, default is 1900
  timeout | Optional time to wait for responses, default is 5 seconds

Blocks for the duration of the timeout.

Returns
  vector of strings containing each received answer

Exceptions

  std::system_error | when system or socket operations fail

Implemented in hueplusplus::LinHttpHandler, and hueplusplus::WinHttpHandler.

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

- include/hueplusplus/IHttpHandler.h