pook.interceptors package

Submodules

pook.interceptors.aiohttp module

pook.interceptors.base module

class pook.interceptors.base.BaseInterceptor(engine)[source]

Bases: object

BaseInterceptor provides a base class for HTTP traffic interceptors implementations.

abstract activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

abstract disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

property name

Exposes the interceptor class name.

pook.interceptors.http module

class pook.interceptors.http.HTTPClientInterceptor(engine)[source]

Bases: BaseInterceptor

urllib / http.client HTTP traffic interceptor.

activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

pook.interceptors.http.HTTPResponse(*args, **kw)[source]
class pook.interceptors.http.SocketMock[source]

Bases: socket

close()[source]

Close the socket. It cannot be used after this call.

makefile(...) an I/O stream connected to the socket[source]

The arguments are as for io.open() after the filename, except the only supported mode values are ‘r’ (default), ‘w’ and ‘b’.

pook.interceptors.urllib3 module

class pook.interceptors.urllib3.FakeChunkedResponseBody(chunks)[source]

Bases: object

close()[source]
flush()[source]
read(amt=-1)[source]
read_chunk(amt=-1, whole=False)[source]
readline()[source]
class pook.interceptors.urllib3.FakeHeaders(iterable=(), /)[source]

Bases: list

get_all(key, default=None)[source]
getheaders(key, default=None)
class pook.interceptors.urllib3.FakeResponse(method, headers)[source]

Bases: object

close()[source]
isclosed()[source]
pook.interceptors.urllib3.HTTPResponse(path, *args, **kw)[source]
class pook.interceptors.urllib3.MockSock[source]

Bases: object

classmethod makefile(*args, **kwargs)[source]
class pook.interceptors.urllib3.Urllib3Interceptor(engine)[source]

Bases: BaseInterceptor

Urllib3 HTTP traffic interceptor.

activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

pook.interceptors.urllib3.body_io(string, encoding='utf-8')[source]
pook.interceptors.urllib3.is_chunked_response(headers)[source]

Module contents

class pook.interceptors.BaseInterceptor(engine)[source]

Bases: object

BaseInterceptor provides a base class for HTTP traffic interceptors implementations.

abstract activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

abstract disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

property name

Exposes the interceptor class name.

class pook.interceptors.HTTPClientInterceptor(engine)[source]

Bases: BaseInterceptor

urllib / http.client HTTP traffic interceptor.

activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

class pook.interceptors.Urllib3Interceptor(engine)[source]

Bases: BaseInterceptor

Urllib3 HTTP traffic interceptor.

activate()[source]

Activates the traffic interceptor. This method must be implemented by any interceptor.

disable()[source]

Disables the traffic interceptor. This method must be implemented by any interceptor.

pook.interceptors.add(*custom_interceptors)[source]

Registers a new HTTP client interceptor.

Parameters:

*custom_interceptors (interceptor) – interceptor(s) to be added.

pook.interceptors.get(name)[source]

Returns an interceptor by class name.

Parameters:

name (str) – interceptor class name or alias.

Returns:

found interceptor instance, otherwise None.

Return type:

interceptor