noc.core.script.http.base

Module Contents

exception noc.core.script.http.base.HTTPError

Bases: noc.core.error.NOCError

default_code
class noc.core.script.http.base.HTTP(script)

Bases: object

HTTPError
get_url(self, path)
get(self, path, headers=None, cached=False, json=False, eof_mark=None, use_basic=False)

Perform HTTP GET request :param path: URI :param headers: Dict of additional headers :param cached: Cache result :param json: Decode json if set to True :param eof_mark: Waiting eof_mark in stream for end session (perhaps device return length 0) :param use_basic: Use basic authentication

post(self, path, data, headers=None, cached=False, json=False, eof_mark=None, use_basic=False)

Perform HTTP GET request :param path: URI :param headers: Dict of additional headers :param cached: Cache result :param json: Decode json if set to True :param eof_mark: Waiting eof_mark in stream for end session (perhaps device return length 0) :param use_basic: Use basic authentication

close(self)
_process_cookies(self, headers)

Process and store cookies from response headers :param headers: :return:

Get cookie name by value :param name: :return: Morsel object or None

_get_effective_headers(self, headers)

Append session headers when necessary. Apply effective cookies :param headers: :return:

set_header(self, name, value)

Set HTTP header to be set with all following requests :param name: :param value: :return:

set_session_id(self, session_id)

Set session_id to be reused by middleware :param session_id: :return: None

ensure_session(self)
setup_session(self)
shutdown_session(self)
setup_middleware(self)