pyneric.http

Representations of HTTP (Hypertext Transport Protocol) standards.

Each supported version of HTTP is represented in a separate subpackage.

v1_1

Represent the Hypertext Transport Protocol version 1.1 standard.

For convenience, public attributes of the core module are reexposed in this module.

core

Represent the Hypertext Transport Protocol 1.1 core standards.

This package module represents core HTTP, whereas additions and extensions are represented in separate modules.

The standard as implemented in this module is defined in the following documents:

This is far from complete and likely never will be, but it may be built upon as needs arise.

class pyneric.http.v1_1.core.Method(token, description, safe, idempotent, cacheable)

Bases: tuple

Class used to represent an HTTP 1.1 request method.

See Section 4 of RFC 7231 for details.

cacheable

Alias for field number 4

description

Alias for field number 1

idempotent

Alias for field number 3

safe

Alias for field number 2

token

Alias for field number 0

pyneric.http.v1_1.core.GET = Method(token='GET', description='Transfer a current representation of the target resource.', safe=True, idempotent=True, cacheable=True)

Representation of the HTTP 1.1 GET request method.

pyneric.http.v1_1.core.HEAD = Method(token='HEAD', description='Same as GET, but only transfer the status line and header section.', safe=True, idempotent=True, cacheable=True)

Representation of the HTTP 1.1 HEAD request method.

pyneric.http.v1_1.core.POST = Method(token='POST', description='Perform resource-specific processing on the request payload.', safe=False, idempotent=False, cacheable=True)

Representation of the HTTP 1.1 POST request method.

pyneric.http.v1_1.core.PUT = Method(token='PUT', description='Replace all current representations of the target resource with the request payload.', safe=False, idempotent=True, cacheable=False)

Representation of the HTTP 1.1 PUT request method.

pyneric.http.v1_1.core.DELETE = Method(token='DELETE', description='Remove all current representations of the target resource.', safe=False, idempotent=True, cacheable=False)

Representation of the HTTP 1.1 DELETE request method.

pyneric.http.v1_1.core.CONNECT = Method(token='CONNECT', description='Establish a tunnel to the server identified by the target resource.', safe=False, idempotent=False, cacheable=False)

Representation of the HTTP 1.1 CONNECT request method.

pyneric.http.v1_1.core.OPTIONS = Method(token='OPTIONS', description='Describe the communication options for the target resource.', safe=True, idempotent=True, cacheable=False)

Representation of the HTTP 1.1 OPTIONS request method.

pyneric.http.v1_1.core.TRACE = Method(token='TRACE', description='Perform a message loop-back test along the path to the target resource.', safe=True, idempotent=True, cacheable=False)

Representation of the HTTP 1.1 TRACE request method.

pyneric.http.v1_1.core.METHODS = {Method(token='GET', description='Transfer a current representation of the target resource.', safe=True, idempotent=True, cacheable=True), Method(token='CONNECT', description='Establish a tunnel to the server identified by the target resource.', safe=False, idempotent=False, cacheable=False), Method(token='PUT', description='Replace all current representations of the target resource with the request payload.', safe=False, idempotent=True, cacheable=False), Method(token='POST', description='Perform resource-specific processing on the request payload.', safe=False, idempotent=False, cacheable=True), Method(token='DELETE', description='Remove all current representations of the target resource.', safe=False, idempotent=True, cacheable=False), Method(token='TRACE', description='Perform a message loop-back test along the path to the target resource.', safe=True, idempotent=True, cacheable=False), Method(token='HEAD', description='Same as GET, but only transfer the status line and header section.', safe=True, idempotent=True, cacheable=True), Method(token='OPTIONS', description='Describe the communication options for the target resource.', safe=True, idempotent=True, cacheable=False)}

A set of all of the HTTP 1.1 request methods.

patch

Represent the PATCH method for HTTP 1.1.

The HTTP PATCH method as implemented in this module is defined in the following document:

IETF RFC 5789

pyneric.http.v1_1.patch.PATCH = Method(token='PATCH', description='Modify the target resource with the request payload.', safe=False, idempotent=False, cacheable=False)

Representation of the HTTP 1.1 PATCH request method.

pyneric.http.v1_1.patch.CACHEABLE_PATCH = Method(token='PATCH', description='Modify the target resource with the request payload.', safe=False, idempotent=False, cacheable=True)

Representation of the HTTP 1.1 cacheable PATCH request method.

Use this responsibly (pun intended, but also serious). From the RFC:

A response to this method is only cacheable if it contains explicit freshness information (such as an Expires header or “Cache-Control: max-age” directive) as well as the Content-Location header matching the Request-URI, indicating that the PATCH response body is a resource representation. A cached PATCH response can only be used to respond to subsequent GET and HEAD requests; it MUST NOT be used to respond to other methods (in particular, PATCH).