本文整理汇总了Python中twisted.web.server.Request.content方法的典型用法代码示例。如果您正苦于以下问题:Python Request.content方法的具体用法?Python Request.content怎么用?Python Request.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.server.Request
的用法示例。
在下文中一共展示了Request.content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeRequest
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import content [as 别名]
def makeRequest(method, path, post_data=None):
req = Request(FakeChannel(), None)
req.prepath = req.postpath = None
req.method = method
req.path = path
req.content = StringIO(post_data)
resource = site.getChildWithDefault(path, req)
return resource.render(req)
示例2: getTextOfPage
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import content [as 别名]
def getTextOfPage(root, page, args=None, return_request=False):
"""This perpetrates several awful hacks."""
if args is not None:
page += '?' + urllib.urlencode(args)
channel = DummyChannel()
channel.site = Site(root)
r = Request(channel, 0)
r.content = StringIO()
r.requestReceived("GET", "/" + page, "1.1")
if return_request:
return channel.transport.written.getvalue(), r
else:
return channel.transport.written.getvalue()
示例3: get_request
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import content [as 别名]
def get_request(self, method, uri, clientproto, headers, data, response):
self.transport = response.transport
r = Request(self, False)
r.method = method
r.clientproto = clientproto
r.path = uri
r.client = response.client
r.host = self.host
r.prepath = []
r.postpath = map(unquote, string.split(r.path[1:], "/"))
r.content = StringIO.StringIO(data)
r.transport = response.transport
return r