Fix :callback and add content-type
parent
0ec7c2f3e6
commit
6cc3e7eb93
|
@ -693,8 +693,11 @@ def After(rss, options):
|
||||||
if item.content:
|
if item.content:
|
||||||
item.content = conv.handle(item.content)
|
item.content = conv.handle(item.content)
|
||||||
|
|
||||||
if options.callback and re.match(r'^[a-zA-Z0-9\.]+$', options.callback) is not None:
|
if options.callback:
|
||||||
|
if re.match(r'^[a-zA-Z0-9\.]+$', options.callback) is not None:
|
||||||
return '%s(%s)' % (options.callback, rss.tojson())
|
return '%s(%s)' % (options.callback, rss.tojson())
|
||||||
|
else:
|
||||||
|
raise MorssException('Invalid callback var name')
|
||||||
elif options.json:
|
elif options.json:
|
||||||
if options.indent:
|
if options.indent:
|
||||||
return rss.tojson(indent=4)
|
return rss.tojson(indent=4)
|
||||||
|
@ -768,6 +771,8 @@ def cgi_app(environ, start_response):
|
||||||
headers['content-type'] = 'text/plain'
|
headers['content-type'] = 'text/plain'
|
||||||
elif options.json:
|
elif options.json:
|
||||||
headers['content-type'] = 'application/json'
|
headers['content-type'] = 'application/json'
|
||||||
|
elif options.callback:
|
||||||
|
headers['content-type'] = 'application/javascript'
|
||||||
elif options.csv:
|
elif options.csv:
|
||||||
headers['content-type'] = 'text/csv'
|
headers['content-type'] = 'text/csv'
|
||||||
headers['content-disposition'] = 'attachment; filename="feed.csv"'
|
headers['content-disposition'] = 'attachment; filename="feed.csv"'
|
||||||
|
|
Loading…
Reference in New Issue