当前位置: 首页>>代码示例>>Python>>正文


Python RequestField.render_headers方法代码示例

本文整理汇总了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")
开发者ID:Nnamso,项目名称:fjord,代码行数:9,代码来源:test_fields.py

示例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'
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:11,代码来源:test_fields.py

示例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')
开发者ID:AngelMarquez,项目名称:urllib3,代码行数:11,代码来源:test_fields.py

示例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')
开发者ID:msrajan,项目名称:urllib3,代码行数:17,代码来源:test_fields.py

示例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')
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:10,代码来源:test_fields.py

示例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')
开发者ID:AngelMarquez,项目名称:urllib3,代码行数:10,代码来源:test_fields.py

示例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",
     )
开发者ID:Nnamso,项目名称:fjord,代码行数:12,代码来源:test_fields.py


注:本文中的urllib3.fields.RequestField.render_headers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。