Frontik's PageHandler contains several methods for making HTTP requests to backends.
def get_url(self, url, data=None, headers=None, connect_timeout=None, request_timeout=None,
callback=None, follow_redirects=True, labels=None, add_to_finish_group=True,
parse_response=True, parse_on_error=False):
def post_url(self, url, data='', headers=None, files=None, connect_timeout=None,
request_timeout=None, callback=None, follow_redirects=True, content_type=None,
labels=None, add_to_finish_group=True, parse_response=True, parse_on_error=False):
def put_url(self, url, data='', headers=None, connect_timeout=None, request_timeout=None,
callback=None, content_type=None, labels=None, add_to_finish_group=True,
parse_response=True, parse_on_error=False):
def delete_url(self, url, data='', headers=None, connect_timeout=None, request_timeout=None,
callback=None, content_type=None, labels=None, add_to_finish_group=True,
parse_response=True, parse_on_error=False):
Method parameters are quite self-explanatory.
- via
labels
parameter you can add custom debug labels to a request. These labels will be displayed on debug page and can be configured per application (see Configuring Frontik application). parse_response
— if set toTrue
, Frontik will try to parse the response body (currently it supports XML and JSON content types) and pass parsed result alongside with the original response to thecallback
. If set toFalse
, the original response body string will be passed instead of the parsed response.parse_on_error
— if set toFalse
, Frontik will not parse the response body with status code >= 300 (None
will be passed to the callback instead of parsed response body). To change this behaviour, setparse_on_error=True
.
Callback must have a following signature:
def callback(parsed_response_body, response):
pass
All callbacks are always added to main AsyncGroup, finish_group
,
except when add_to_finish_group
parameter is set to False
. Only after all requests and callbacks
are finished, AsyncGroup is marked as completed and postprocessing
and templating takes place.