请求强制标题

时间:2015-08-12 22:18:24

标签: python python-requests

我目前正在使用请求库传入标题。

我相信文档说明某些事件优先于自定义标题。

有没有办法让您的自定义标题优先?

例如,我想要content-type 'application/vnd.reviewboard.org.diff.data+json'

但是,响应继续表明不同的标题:

requests.get('url_here', headers={'content-type':'application/vnd.reviewboard.org.diff.data+json'}).__dict__

将返回

'content-type': 'application/vnd.reviewboard.org.file+json'

如果相关,我正试图点击审核委员会的终端

https://www.reviewboard.org/docs/manual/2.5/webapi/2.0/resources/file-diff/

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试指定在响应中收到的内容类型,而不是您的请求的内容类型。因此,您应该使用Accept标题,而不是content-type