本文整理汇总了Python中trac.web.api.Request.send_header方法的典型用法代码示例。如果您正苦于以下问题:Python Request.send_header方法的具体用法?Python Request.send_header怎么用?Python Request.send_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.web.api.Request
的用法示例。
在下文中一共展示了Request.send_header方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_unicode
# 需要导入模块: from trac.web.api import Request [as 别名]
# 或者: from trac.web.api.Request import send_header [as 别名]
def test_write_unicode(self):
buf = StringIO()
def write(data):
buf.write(data)
def start_response(status, headers):
return write
environ = self._make_environ(method='HEAD')
req = Request(environ, start_response)
req.send_header('Content-Type', 'text/plain;charset=utf-8')
req.write(u'Föö')
self.assertEqual('Föö', buf.getvalue())
示例2: test_write_unicode
# 需要导入模块: from trac.web.api import Request [as 别名]
# 或者: from trac.web.api.Request import send_header [as 别名]
def test_write_unicode(self):
buf = StringIO()
def write(data):
buf.write(data)
def start_response(status, headers):
return write
environ = self._make_environ(method='HEAD')
req = Request(environ, start_response)
req.send_header('Content-Type', 'text/plain;charset=utf-8')
req.send_header('Content-Length', 0)
# anyway we're not supposed to send unicode, so we get a ValueError
self.assertRaises(ValueError, req.write, u'Föö')
示例3: test_write_iterable
# 需要导入模块: from trac.web.api import Request [as 别名]
# 或者: from trac.web.api.Request import send_header [as 别名]
def test_write_iterable(self):
buf = StringIO()
def write(data):
buf.write(data)
def start_response(status, headers):
return write
environ = self._make_environ(method='GET')
buf = StringIO()
req = Request(environ, start_response)
req.send_header('Content-Type', 'text/plain;charset=utf-8')
req.write(('Foo', 'bar', 'baz'))
self.assertEqual('Foobarbaz', buf.getvalue())
示例4: test_write_unicode
# 需要导入模块: from trac.web.api import Request [as 别名]
# 或者: from trac.web.api.Request import send_header [as 别名]
def test_write_unicode(self):
buf = StringIO()
def write(data):
buf.write(data)
def start_response(status, headers):
return write
environ = self._make_environ(method="HEAD")
req = Request(environ, start_response)
req.send_header("Content-Type", "text/plain;charset=utf-8")
req.write(u"Föö")
self.assertEqual("Föö", buf.getvalue())