arjuna.tpi.httpauto.session module

class arjuna.tpi.httpauto.session.HttpCookie(session, cookie)

Bases: object

property httponly
property secure
property value
class arjuna.tpi.httpauto.session.HttpSession(*, url=None, oauth_token=None, request_content_handler=None, headers=None, max_redirects=None, auth=None, proxy=None, _auto_session=True)

Bases: object

Create an HTTP Session. Does automatic cookie management.

Keyword Arguments
  • url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.

  • oauth_token – OAuth 2.0 Bearer token for this session.

  • request_content_handler – Default content type handler for requests sent in this session. Overridable in individual sender methods. Default is Http.content.urlencoded.

  • headers – HTTP headers to be added to request headers made by this session.

  • max_redirects – Maximum number of redirects allowed for a request. Default is 30.

  • auth – HTTP Authentication object: Basic/Digest.

  • proxy – Proxies dict to be associated with this session.

add_cookies(cookie_dict)

Add cookies to the session.

property auth

HTTP Authentication object.

property cookies

All current cookie name/values in this session object.

delete(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP DELETE request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

get(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP GET request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

head(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP HEAD request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property headers

Request headers.

message(msg_name=None, **fargs)arjuna.tpi.httpauto.response.HttpResponse
options(route, *, content=None, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP PUT request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property parsed_cookies

All current cookie name and corresponding HttpCookie object in this session object.

patch(route, *, content=None, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP PUT request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

post(route, *, content=None, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP POST request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

put(route, *, content=None, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: float = None, pretty_url=False, query_params=None, **named_query_params)arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP PUT request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property request_content_handler

Request content handler for content formatting.

property url

Base URL for this session.