本文整理汇总了Python中urllib3.fields.RequestField.render_headers方法的典型用法代码示例。如果您正苦于以下问题:Python RequestField.render_headers方法的具体用法?Python RequestField.render_headers怎么用?Python RequestField.render_headers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib3.fields.RequestField
的用法示例。
在下文中一共展示了RequestField.render_headers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_create(self):
simple_field = RequestField("somename", "data")
self.assertEqual(simple_field.render_headers(), "\r\n")
filename_field = RequestField("somename", "data", filename="somefile.txt")
self.assertEqual(filename_field.render_headers(), "\r\n")
headers_field = RequestField("somename", "data", headers={"Content-Length": 4})
self.assertEqual(headers_field.render_headers(), "Content-Length: 4\r\n\r\n")
示例2: test_create
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_create(self):
simple_field = RequestField('somename', 'data')
assert simple_field.render_headers() == '\r\n'
filename_field = RequestField('somename', 'data',
filename='somefile.txt')
assert filename_field.render_headers() == '\r\n'
headers_field = RequestField('somename', 'data',
headers={'Content-Length': 4})
assert headers_field.render_headers() == 'Content-Length: 4\r\n\r\n'
示例3: test_create
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_create(self):
simple_field = RequestField('somename', 'data')
self.assertEqual(simple_field.render_headers(), '\r\n')
filename_field = RequestField('somename', 'data', filename='somefile.txt')
self.assertEqual(filename_field.render_headers(), '\r\n')
headers_field = RequestField('somename', 'data', headers={'Content-Length': 4})
self.assertEqual(headers_field.render_headers(),
'Content-Length: 4\r\n'
'\r\n')
示例4: test_create
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_create(self):
simple_field = RequestField('somename', 'data')
self.assertEqual(simple_field.render_headers(),
'Content-Disposition: form-data; name="somename"\r\n\r\n')
filename_field = RequestField('somename', 'data',
filename='somefile.txt')
self.assertEqual(filename_field.render_headers(),
'Content-Disposition: form-data; name="somename"; filename="somefile.txt"\r\n'
'Content-Type: text/plain\r\n'
'\r\n')
headers_field = RequestField('somename', 'data',
headers={'Content-Length': 4})
self.assertEqual(headers_field.render_headers(),
'Content-Disposition: form-data; name="somename"\r\n'
'Content-Length: 4\r\n\r\n')
示例5: test_make_multipart_empty_filename
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_make_multipart_empty_filename(self):
field = RequestField('somename', 'data', '')
field.make_multipart(content_type='application/octet-stream')
assert (
field.render_headers() ==
'Content-Disposition: form-data; name="somename"; filename=""\r\n'
'Content-Type: application/octet-stream\r\n'
'\r\n')
示例6: test_make_multipart
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_make_multipart(self):
field = RequestField('somename', 'data')
field.make_multipart(content_type='image/jpg', content_location='/test')
self.assertEqual(field.render_headers(),
'Content-Disposition: form-data; name="somename"\r\n'
'Content-Type: image/jpg\r\n'
'Content-Location: /test\r\n'
'\r\n')
示例7: test_make_multipart
# 需要导入模块: from urllib3.fields import RequestField [as 别名]
# 或者: from urllib3.fields.RequestField import render_headers [as 别名]
def test_make_multipart(self):
field = RequestField("somename", "data")
field.make_multipart(content_type="image/jpg", content_location="/test")
self.assertEqual(
field.render_headers(),
'Content-Disposition: form-data; name="somename"\r\n'
"Content-Type: image/jpg\r\n"
"Content-Location: /test\r\n"
"\r\n",
)