检查标头是否为自定义

时间:2017-06-24 21:25:10

标签: python http flask

有没有办法在python中检查请求标头是自定义还是默认?从字面上看,是否可以区分这两个卷曲请求?

curl -si 127.0.0.1:8080/api/key1 -XPUT -d '{"text": "hello"}'

curl -si 127.0.0.1:8080/api/key1 -XPUT -d '{"text": "hello"}' -H 'Content-Type: application/x-www-form-urlencoded'

1 个答案:

答案 0 :(得分:0)

不,没有办法在烧瓶或任何语言/框架中执行此操作。请求只是通过HTTP协议发送的字符串,具有相同字符串的任何两个请求都是等效的。默认情况下,curl中PUT请求的Content-Type为fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)。具体指定此内容类型将导致curl通过HTTP发送相同的字符串。

证明

application/x-www-form-urlencoded