10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::http Namespace Reference

Detailed Description

HTTP-related services.

This namespace contains services related to HTTP. This particular namespace itself contains service interface for a generic HTTP-client, which is used in across the 10Duke C++ client. This allows the actual HTTP-implementation to be changed, if necessary.

Namespaces

namespace  curl
 Implementation of HTTP-client using libcurl.
namespace  server
 Simple HTTP-server.

Classes

class  BadRequest
 Thrown for HTTP status code 400 "BadRequest". More...
class  ClientError
 4xx-series, base class for many 4xx-exceptions. More...
class  Forbidden
 Thrown for HTTP status code 403, "Forbidden". More...
class  HTTPCall
 HTTP-call which executes the request and returns HTTPResponse. More...
class  HTTPClient
 A simple HTTP-client. More...
class  HTTPException
 A generic HTTP-exception. More...
class  HTTPRequest
 HTTP-request, which contains all necessary details to construct the request. More...
class  HTTPRequestAuthenticator
 This is a service, that can be added to tenduke::http::HTTPRequest to add authentication information to the request. More...
class  HTTPRequestBuilder
 Builds HTTPRequest. More...
class  HTTPRequestException
 This exception is thrown when a HTTP-request fails for HTTP-specific reasons in the client end. More...
class  HTTPResponse
 A HTTP Response. More...
class  HTTPResponseException
 This exception is thrown when HTTP-request fails because of HTTP-statuscode. More...
class  HTTPResponseToException
 Utility service to throw an exception based on tenduke::http::HTTPResponse. More...
class  NotFound
 Thrown for HTTP status code 404, "Not Found". More...
class  ServerError
 5xx-error, base class for 5xx-exceptions. More...
class  Unauthorized
 Thrown for HTTP status code 401, "Unauthorized". More...

Functions

void validateHTTPHeader (const std::string &name, const std::string &value)
 Checks that a request header can be sent as is, without changing the meaning of the request.

Variables

const long DEFAULT_CONNECTION_TIMEOUT_MS = 30L * 1000L
 Default connection time out in milliseconds.
const long DEFAULT_TIMEOUT_MS = 60L * 1000L
 Default total time out in milliseconds.
const std::size_t DEFAULT_MAX_RESPONSE_BODY_SIZE = 10 * 1024 * 1024
 Default maximum size of a response body in bytes (10 MiB).

Function Documentation

◆ validateHTTPHeader()

void tenduke::http::validateHTTPHeader ( const std::string & name,
const std::string & value )

Checks that a request header can be sent as is, without changing the meaning of the request.

Accepts (see https://www.rfc-editor.org/rfc/rfc9110#section-5):

  • name: a non-empty token, i.e. letters, digits and !#$%&'*+-.^_`|~
  • value: any characters except control characters, horizontal tab is allowed. Non-ASCII (e.g. UTF-8) bytes are accepted.

Rejects e.g. CR and LF, which would end the header and let the rest of the value inject extra headers.

Parameters
namename of the header
valuevalue of the header
Exceptions
tenduke::http::HTTPRequestExceptionif the name or the value is not valid

Variable Documentation

◆ DEFAULT_MAX_RESPONSE_BODY_SIZE

const std::size_t tenduke::http::DEFAULT_MAX_RESPONSE_BODY_SIZE = 10 * 1024 * 1024

Default maximum size of a response body in bytes (10 MiB).

A larger response is aborted.

◆ DEFAULT_TIMEOUT_MS

const long tenduke::http::DEFAULT_TIMEOUT_MS = 60L * 1000L

Default total time out in milliseconds.

A time out of 0 means the request does not time out.