/usr/share/pyshared/scrapy/utils/txweb.py is in python-scrapy 0.14.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from twisted.web import resource
from scrapy.utils.py26 import json
class JsonResource(resource.Resource):
json_encoder = json.JSONEncoder()
def render(self, txrequest):
r = resource.Resource.render(self, txrequest)
return self.render_object(r, txrequest)
def render_object(self, obj, txrequest):
r = self.json_encoder.encode(obj) + "\n"
txrequest.setHeader('Content-Type', 'application/json')
txrequest.setHeader('Content-Length', len(r))
return r
|