def patch(self, route, *, content=NotSet(), 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) -> HttpResponse: request = _HttpRequest(self, self.__route(route), method="patch", label=label, content=content, xcodes=xcodes, headers=headers, cookies=cookies, allow_redirects=allow_redirects, auth=auth, timeout=timeout, pretty_url=pretty_url, query_params=query_params, **named_query_params) return self._send(request)
def html(cls, content=NotSet()): ''' Send HTML content. Content-Type is sent as “text/html” ''' if isinstance(content, NotSet): return _HttpContent(content=None, type=cls.get_content_type(cls.html)) return _HttpContent(content=content, type=cls.get_content_type(cls.html))
def urlencoded(cls, content=NotSet()): ''' Send a dictionary of key-values in URL encoded format. Content-Type is sent as “application/x-www-form-urlencoded” ''' if isinstance(content, NotSet): return _HttpContent(content=None, type=cls.get_content_type(cls.urlencoded)) if content: content = urlencode(content) return _HttpContent(content=content, type=cls.get_content_type(cls.urlencoded))
def json(cls, content=NotSet()): ''' Send a dictionary of key-values as JSON. Content-Type is sent as “application/json” ''' if isinstance(content, NotSet): return _HttpContent(content=None, type=cls.get_content_type(cls.json)) from arjuna.core.fmt import arj_convert content = json.dumps(arj_convert(content), indent=2) return _HttpContent(content=content, type=cls.get_content_type(cls.json))
def patch(self, route, *, content=NotSet(), 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) -> HttpResponse: ''' Sends an HTTP PATCH request. Arguments: 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'. Default is a NotSet object. 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. ''' return self._session.patch(route, label=label, content=content, xcodes=xcodes, headers=headers, cookies=cookies, allow_redirects=allow_redirects, auth=auth, timeout=timeout, pretty_url=pretty_url, query_params=query_params, **named_query_params)