我正在尝试在wiremck中发布文件并在映射中配置文件,如下所示。在响应中,我看到Content-Type、Content-Disposion等,有没有办法禁用它?
POST文件
http://localhost:8080/__admin/files/some.json
的内容
{
"user": "xxx"
}
创建映射
http://localhost:8080/__admin/mappings
{
"request": {
"method": "GET",
"url": "/some"
},
"response": {
"status": 200,
"bodyFileName": "some.json",
"headers": {
"Content-Type": [
"application/json;charset=UTF-8"
]
}
}
}
检查api
http://localhost:8080/some
回应:
----------------------------228585284577179878202292
Content-Disposition: form-data; name="file"; filename="some.json"
Content-Type: application/json
{
"user": "xxx"
}
----------------------------228585284577179878202292--
如您所见,实际响应中还有类似以下的附加内容。想要禁用以下内容。如何做到这一点?
----------------------------228585284577179878202292
Content-Disposition: form-data; name="file"; filename="some.json"
Content-Type: application/json
----------------------------228585284577179878202292--
上传文件时选择二进制而不是form-data。然后它只返回实际响应…
{
"user": "xxx"
}
如果您通过HTTP请求将文件放入wiremck实例,正如@Minisha所说,请在您的put请求中添加'Content-type':'二进制'标头。以下是python请求的示例:
headers = {'Content-type': 'binary'}
requests.put(url=mock_wire_files_url_file_name, data=open(your_file, 'rb'), headers=headers)