Getter | Setter | Description | Default |
\ref Url() |
\ref SetUrl() |
The URL. This must start with http or https. |
Defaults to an empty \ref BUrl |
\ref Fields() |
\ref SetFields() |
Additional fields set in the request header. |
Defaults with no additional fields |
\ref Method() |
\ref SetMethod() |
The HTTP method for the request |
Defaults to \ref BHttpMethod::Get |
\ref MaxRedirections() |
\ref SetMaxRedirections() |
How many redirections should be followed. Set to 0 to disable. |
Defaults to 8 redirections per request |
\ref RequestBody() |
\ref SetRequestBody() |
Body contents that is sent with the request. |
Defaults to an empty body |
\ref StopOnError() |
\ref SetStopOnError() |
Stop parsing the server response when there is a client or server error. |
Defaults to \a false |
\ref Timeout() |
\ref SetTimeout() |
The timeout determines how long is waited for the server to respond |
\c B_INFINITE_TIMEOUT |
\since Haiku R1
*/
/*!
\name Constructors and Destructor
*/
//! @{
/*!
\fn BHttpRequest::BHttpRequest()
\brief Construct an empty HTTP request.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\since Haiku R1
*/
/*!
\fn BHttpRequest::BHttpRequest(const BUrl &url)
\brief Construct a HTTP request for an \a url.
\param url A valid URL with the \c http or \c https protocol.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\exception BUnsupportedProtocol This exception is raised when the protocol of the URL cannot be
handled.
\exception BInvalidUrl This exception is raised when the \a url is invalid.
\since Haiku R1
*/
/*!
\fn BHttpRequest::BHttpRequest(const BHttpRequest &other)=delete
\brief Copying is not allowed.
\since Haiku R1
*/
/*!
\fn BHttpRequest::BHttpRequest(BHttpRequest &&other) noexcept
\brief Move constructor.
After a move, the \a other object is left in an empty state.
\param other The request to move data from.
\since Haiku R1
*/
/*!
\fn BPrivate::Network::BHttpRequest::~BHttpRequest()
\brief Destructor
\since Haiku R1
*/
//! @}
/*!
\name Assignment operators
*/
//! @{
/*!
\fn BHttpRequest& BHttpRequest::operator=(const BHttpRequest &other)=delete
\brief Copy assignment is not allowed.
\since Haiku R1
*/
/*!
\fn BHttpRequest& BHttpRequest::operator=(BHttpRequest &&other) noexcept
\brief Move assignment
After a move, the \a other object is left in an empty state.
\param other The request to move data from.
\since Haiku R1
*/
//! @}
/*!
\name Valid or empty
*/
//! @{
/*!
\fn bool BHttpRequest::IsEmpty() const noexcept
\brief Check if the request is valid or empty
\retval true The request is empty.
\retval false The request is valid.
\since Haiku R1
*/
//! @}
/*!
\name Current Options
*/
//! @{
/*!
\fn const BHttpAuthentication* BHttpRequest::Authentication() const noexcept
\brief Get the credentials for the authentication for the request.
\return When no credentials are set for this request, the method returns a \c nullptr.
Otherwise, it will return a pointer to the current BHttpAuthentication data set for this
request.
\since Haiku R1
*/
/*!
\fn const BHttpFields& BHttpRequest::Fields() const noexcept
\brief Get the additional header fields set for the request.
The returned header fields may be empty if no additional header fields were set.
\since Haiku R1
*/
/*!
\fn const BHttpMethod& BHttpRequest::Method() const noexcept
\brief Get the current method for the request.
This will either return the custom value set for this request, or the default as is listed in
the overview documentation of this class.
\since Haiku R1
*/
/*!
\fn uint8 BHttpRequest::MaxRedirections() const noexcept
\brief Get the current redirection options for this request.
\see \ref BHttpRequest::SetMaxRedirections() for details on the options.
\since Haiku R1
*/
/*!
\fn const BHttpRequest::Body* BHttpRequest::RequestBody() const noexcept
\brief Get the details of the custom body set for the request.
\return When no body is set for this request, the method returns a \c nullptr.
Otherwise, it will return a pointer to a struct that describes the current body.
\since Haiku R1
*/
/*!
\fn bool BHttpRequest::StopOnError() const noexcept
\brief Is the request set to parse the full response on error.
\retval true When encountering a HTTP status of the client error class (4xx) or server error
class (5xx), then the response will not be parsed.
\retval false The full response will be parsed, even with an error status code.
\since Haiku R1
*/
/*!
\fn bigtime_t BHttpRequest::Timeout() const noexcept
\brief Get the current timeout for the server to respond.
\since Haiku R1
*/
/*!
\fn const BUrl& BHttpRequest::Url() const noexcept
\brief Get the current Url for the request.
This will either return the custom value set for this request, or the default as is listed in
the overview documentation of this class.
\since Haiku R1
*/
//! @}
/*!
\name Setting Options
*/
//! @{
/*!
\fn void BHttpRequest::SetAuthentication(const BHttpAuthentication &authentication)
\brief Set the credentials to enable basic authentication for the request.
The Basic authorization line is added to the request upon setting the request details. There is
no support for other authentication schemes, like digest authentication.
\param authentication The credentials to apply to the request.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\since Haiku R1
*/
/*!
\fn void BHttpRequest::SetFields(const BHttpFields &fields)
\brief Set additional header \a fields for this request.
There are a few reserved fields, which cannot be set as optional fields. These currently are:
* \c Host
* \c Accept-Encoding
* \c Connection
* \c Content-Type
* \c Content-Length
\param fields Additional fields for the header of the request.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\exception BHttpFields::InvalidData This exception is raised when the \a fields contain
reserved fields.
\since Haiku R1
*/
/*!
\fn void BHttpRequest::SetMethod(const BHttpMethod &method)
\brief Set the \a method for this request.
Note that there currently is no additional validation done on any semantical incompatibilities.
This means that it is currently allowed to do a \c GET or \c HEAD request with data, while that
is forbidden by the standard.
\param method The method to use for the request.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\since Haiku R1
*/
/*!
\fn void BHttpRequest::SetMaxRedirections(uint8 maxRedirections)
\brief Set the redirection options for this request.
The HTTP protocol allows the server to redirect requests if the resources have moved to a new
location. For your convenience, you can instruct the network services kit to follow these
redirections. You can set how many redirects should be followed. The maximum value is that of
an unsigned 8 bit int, so maximum is 256 redirects. This prevents the request from staying
stuck in a redirection loop.
If redirects are set to 0, or the maximum number of redirects have been processed, then the
response will be set to the actual (last) received redirection response.
\param maxRedirections The number of redirections to follow. Set to 0 to disable.
\exception std::bad_alloc This exception may be raised if it is impossible to allocate memory.
\since Haiku R1
*/
/*!
\fn void BHttpRequest::SetRequestBody(std::unique_ptr