Add comments and docstring for the send method
Add docstring explaining the basics of the send method.pull/1520/head
parent
9f843993b6
commit
851e3b2aa4
|
@ -79,6 +79,16 @@ class Api(object):
|
|||
IdentityManager.save(data)
|
||||
|
||||
def send(self, params):
|
||||
""" Send request to mycroft backend.
|
||||
The method handles Etags and will return a cached response value
|
||||
if nothing has changed on the remote.
|
||||
|
||||
Arguments:
|
||||
params (dict): request parameters
|
||||
|
||||
Returns:
|
||||
Requests response object.
|
||||
"""
|
||||
query_data = frozenset(params.get('query', {}).items())
|
||||
params_key = (params.get('path'), query_data)
|
||||
etag = self.params_to_etag.get(params_key)
|
||||
|
@ -90,6 +100,8 @@ class Api(object):
|
|||
query = self.build_query(params)
|
||||
url = self.build_url(params)
|
||||
|
||||
# For an introduction to the Etag feature check out:
|
||||
# https://en.wikipedia.org/wiki/HTTP_ETag
|
||||
if etag:
|
||||
headers['If-None-Match'] = etag
|
||||
|
||||
|
|
Loading…
Reference in New Issue