HTTP Utilities

Module: ppc_robot_lib.utils.http

HTTP_GATEWAY_ERRORS = {502, 503, 504}

Status codes used for HTTP Gateway errors.

RATE_LIMIT_ERRORS = {415, 429}

Status codes used for rate limiting errors.

SERVER_ERRORS = {500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511}

Status codes used for all server-side errors.

get_status_text(status_code)[source]

Gets a human-friendly description of the status code.

Example:

>>> get_status_text(404)
'404 Not Found'
Parameters:

status_code (int) – Status code.

Return type:

str

Returns:

Status code description, or status code itself when a non-standard status code is passed.

is_gateway_error(status_code)[source]

Checks if the given status code is a gateway error.

Parameters:

status_code (int) – Status code.

Return type:

bool

Returns:

True if the status code represents a gateway error.

is_rate_limit_error(status_code)[source]

Checks if the given status code is a rate limiting error.

Parameters:

status_code – Status code.

Returns:

True if the status code represents a commonly used rate limiting error.

is_server_error(status_code)[source]

Checks if the given status code is a server error.

Parameters:

status_code – Status code.

Returns:

True if the status code represents a server error.