NetServices: Serialize the header of a BHttpRequest to a string

Change-Id: Ib1e22536a0b39dc6e9461e7993ea6784f1ea0e2f
This commit is contained in:
Niels Sascha Reedijk
2022-03-30 07:38:57 +01:00
parent 3b172a3dc6
commit d9a4c6070c
8 changed files with 169 additions and 1 deletions
+17
View File
@@ -476,6 +476,23 @@ namespace Network {
*/
/*!
\fn void BHttpFields::AddFields(std::initializer_list< Field > fields)
\brief Add a list of fields.
This enables you to add a list of \ref BHttpFields::Field objects. Like \ref AddField(), the
fields are added in the the original order, though if there are duplicate keys within the
\a fields list, or there are existing keys in the object, they will be grouped together in
sequence.
\exception std::bad_alloc Error in case memory cannot be allocated.
\exception BHttpFields::InvalidInput This error indicates that some of the names or values in
the list do not adhere to the HTTP specification.
\since Haiku R1
*/
/*!
\fn void BHttpFields::RemoveField(const std::string_view &name) noexcept
\brief Remove all fields with the \a name.
+48
View File
@@ -473,6 +473,54 @@ namespace Network {
//! @}
/*!
\name Serialization
*/
//! @{
/*!
\fn ssize_t BHttpRequest::SerializeHeaderTo(BDataIO *target) const
\brief Serialize the HTTP Header of this request to the \a target.
The HTTP header consists of the request line, and the fields, serialized as text according to
the HTTP specification.
\param target The \ref BDataIO object to write the header to
\return The total number of byte size of the header.
\exception BSystemError In case there is an error when calling the \ref BDataIO::Write() call
of the provided \a target. Note that writing the string is \em not transactional, and that
the error can occur while a part of the header has already been written.
\exception std::bad_alloc In case it is not possible to allocate internal buffers.
\since Haiku R1
*/
/*!
\fn BString BHttpRequest::HeaderToString() const
\brief Serialize the HTTP Header of this request to a string.
The HTTP header consists of the request line, and the fields, serialized as text according to
the HTTP specification.
This method can be used to debug requests.
\return A new string that represents the HTTP request.
\exception std::bad_alloc In case it is not possible to allocate memory for the output string.
\since Haiku R1
*/
//! @}
} // namespace Network
} // namespace BPrivate
+1 -1
View File
@@ -219,7 +219,7 @@ namespace Network {
to initialize it to \c __PRETTY_FUNCTION__ by default.
\param type The error type that describes what the issue was that prevented the completion of
the request.
\param error Optional underlying system error. See the \ref BNetworkRequestError::ErrorType
\param errorCode Optional underlying system error. See the \ref BNetworkRequestError::ErrorType
documentation on which error types expect a system error.
\since Haiku R1