mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Merge pull request #610 from JackDandy/feature/ChangeTornadoJsonP
Change API response header for JSON content type and the return of JS…
This commit is contained in:
commit
f1c70d99b1
2 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
|||
* Update xmltodict library 0.9.2 (579a005) to 0.9.2 (eac0031)
|
||||
* Update Tornado Web Server 4.3.dev1 (1b6157d) to 4.4.dev1 (c2b4d05)
|
||||
* Update change to suppress reporting of Tornado exception error 1 to updated package (ref:hacks.txt)
|
||||
* Change API response header for JSON content type and the return of JSONP data
|
||||
|
||||
|
||||
### 0.11.0 (2016-01-10 22:30:00 UTC)
|
||||
|
|
|
@ -135,19 +135,19 @@ class Api(webserve.BaseHandler):
|
|||
self.finish(outputCallback(outDict))
|
||||
|
||||
def _out_as_json(self, dict):
|
||||
self.set_header('Content-Type', 'application/json')
|
||||
self.set_header('Content-Type', 'application/json; charset=UTF-8')
|
||||
try:
|
||||
out = json.dumps(dict, indent=self.intent, sort_keys=True)
|
||||
if 'jsonp' in self.request.query_arguments:
|
||||
out = self.request.arguments['jsonp'] + '(' + out + ');' # wrap with JSONP call if requested
|
||||
callback = self.get_query_argument('callback', None) or self.get_query_argument('jsonp', None)
|
||||
if None is not callback:
|
||||
out = '%s(%s);' % (callback, out) # wrap with JSONP call if requested
|
||||
|
||||
except Exception as e: # if we fail to generate the output fake an error
|
||||
logger.log(u'API :: ' + traceback.format_exc(), logger.DEBUG)
|
||||
out = '{"result":"' + result_type_map[RESULT_ERROR] + '", "message": "error while composing output: "' + ex(
|
||||
e) + '"}'
|
||||
|
||||
tornado_write_hack_dict = {'unwrap_json': out}
|
||||
return tornado_write_hack_dict
|
||||
return out
|
||||
|
||||
def _grand_access(self, realKey, apiKey, args, kwargs):
|
||||
""" validate api key and log result """
|
||||
|
|
Loading…
Reference in a new issue