Utilities

This section shows general objects and helper functions that are used with this package.

class balderhub.http.lib.utils.HttpRequestMessage(url: Url, method: HttpMethod)

Bases: object

Represents an HTTP request message consisting of a URL and an HTTP method.

This class encapsulates the essential parts of an HTTP request.

Parameters:
  • url – The target URL for the HTTP request.

  • method – The HTTP method to be used for the request.

property method: HttpMethod

The HTTP method to be used for the request.

property url: Url

The target URL for the HTTP request.

class balderhub.http.lib.utils.Response(status_code: int, url: ~balderhub.url.lib.utils.url.Url, content: bytes, history: list[balderhub.http.lib.utils.response.Response] = <factory>)

Bases: object

Represents an HTTP response received from a request made to a specific URL.

This class encapsulates the details of an HTTP response, including the status code, the URL from which the response was received, the content of the response, and the history of any preceding responses (e.g., in cases of redirects or retries).

Variables:
  • status_code – Status code returned by the server.

  • url – The URL from which the response was received.

  • content – The raw binary content of the response.

  • history – List of preceding Response objects that represent the redirection or retry history leading to this response. Defaults to an empty list.

Enums

class balderhub.http.lib.utils.HttpMethod(value)

Bases: Enum

This enum describes all common HTTP methods supported by BalderHub.

Further functions

balderhub.http.lib.utils.functions.convert_requests_response(response: Response) Response

Converts a requests.Response object into the BalderHub Response object.

Parameters:

response – A requests.Response object that contains metadata, content, and history of the HTTP request/response cycle.

Returns:

A transformed Response object containing the status code, URL, content, and processed history of the requests.Response.