Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

anvil.http Module

Classes

HttpError

Create a new ‘HttpError’ object

Constructor

HttpError()

HttpError Attributes

content - content

The content returned by the request (eg the body of a 404 response)

status - number

The numeric HTTP status error (eg 404 for “not found”).

Status will be 0 for errors that prevent the request completing at all (eg cross-origin policy in the browser).


UrlEncodingError

Create a new ‘UrlEncodingError’ object

Constructor

UrlEncodingError()

Functions

request(url, [method="GET"], [data=None], [json=False], [headers=None], [username=None], [password=None])

Make an HTTP request to the specified URL.

If json=True, the response is parsed into Python objects (dicts/lists/etc), and ‘data’ is JSON-encoded before sending.

‘headers’ can be a dict of strings to set HTTP headers. If specified, ‘username’ and ‘password’ will be used to perform HTTP Basic authentication.


url_decode(string_to_encode)

URL-decode a string. Raises UrlEncodingError on failure.


url_encode(string_to_encode)

URL-encode a string



anvil.http