Package nbxmpp :: Module transports_nb :: Class NonBlockingHTTP

[hide private]
[frames] | no frames]

# Class NonBlockingHTTP

source code

Socket wrapper that creates HTTP message out of sent data and peels-off HTTP headers from incoming messages

Instance Methods | [hide private]

__init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, on_http_request_possible, on_persistent_fallback, http_dict, proxy_dict=None) Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor | source code

http_send(self, raw_data, now=False) | source code

_on_receive(self, data) Preceeds passing received data to owner class. Gets rid of HTTP headers and checks them. | source code

build_http_message(self, httpbody, method=`'``POST``'`) Builds http message with given body. Values for headers and status line fields are taken from class variables | source code

parse_http_message(self, message) (statusline - list of e.g. ['HTTP/1.1', '200', 'OK'], | source code

Inherited from `NonBlockingTCP`: `connect`, `disconnect`, `encode_stanza`, `pollend`, `pollin`, `pollout`, `read_timeout`, `remove_timeout`, `send`, `set_timeout`, `start_disconnect`, `tls_init`

Inherited from `NonBlockingTCP` (private): `_connect_to_proxy`, `_do_receive`, `_do_send`, `_on_connect`, `_plug_idle`

Inherited from `NonBlockingTransport`: `get_fd`, `get_state`, `onreceive`, `plugin`, `plugout`, `read_timeout2`, `renew_send_timeout`, `renew_send_timeout2`, `set_send_timeout`, `set_send_timeout2`, `set_state`, `set_timeout2`

Inherited from `NonBlockingTransport` (private): `_on_connect_failure`, `_tcp_connecting_started`

Inherited from `plugin.PlugIn`: `PlugIn`, `PlugOut`

Class Methods | [hide private]

Inherited from `plugin.PlugIn`: `get_instance`

Instance Variables | [hide private]

Inherited from `idlequeue.IdleObject`: `fd`

Method Details | [hide private]

### __init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, certs, on_http_request_possible, on_persistent_fallback, http_dict, proxy_dict=None)
(Constructor)

source code

Each trasport class can have different constructor but it has to have at least all the arguments of NonBlockingTransport constructor

Parameters:
  - `on_http_request_possible` - method to call when HTTP request to socket owned by transport is possible.
  - `on_persistent_fallback` - callback called when server ends TCP connection. It doesn't have to be fatal for HTTP session.
  - `http_dict` - dictionary with data for HTTP request and headers
Overrides: idlequeue.IdleObject.__init__

### http_send(self, raw_data, now=False)

source code

### _on_receive(self, data)

source code

Preceeds passing received data to owner class. Gets rid of HTTP headers and checks them.

Overrides: NonBlockingTCP._on_receive

### build_http_message(self, httpbody, method=`'``POST``'`)

source code

Builds http message with given body. Values for headers and status line fields are taken from class variables

### parse_http_message(self, message)

source code

Split http message into a tuple:

  - (statusline - list of e.g. ['HTTP/1.1', '200', 'OK'],

  - headers - dictionary of headers e.g. {'Content-Length': '604',

      'Content-Type': 'text/xml; charset=utf-8'},

  - httpbody - string with http body)

  - http_rest - what is left in the message after a full HTTP header + body