简体   繁体   English

在tcl http中将默认的http标头请求设置为空

[英]set default http header request to empty in tcl http

I would like to set the default http hrader in Tcl http package to empty and then selecetively put some header on my own using a dictionary. 我想将Tcl http包中的默认http hrader设置为空,然后使用字典自行选择地放置一些标头。 I need to do this becasue I see many items (like sock, binary, -binary, -strict, queryoffset etc) in my Tcl http request header which are not present in the header specified by other web browser like firefox. 我需要这样做,因为我在Tcl http请求标头中看到许多项(例如sock,binary,-binary,-strict,queryoffset等),而其他项目(如firefox)指定的标头中没有这些项目。 I get correct response in broswer so I want exactly those heater which are send by the brower. 我在浏览器中得到正确的响应,因此我需要的是浏览器发送的加热器。 For this I need to set the default http header in Tcl http package to empty, and mannually set the headers (which I can do). 为此,我需要将Tcl http包中的默认http标头设置为空,并手动设置标头(我可以这样做)。 How do I empty the default headers? 如何清空默认标题?

I'm not quite sure which header you've got a problem with, but the majority of headers can be set quite easily via the -headers option to http::geturl : 我不太确定您遇到哪个标题,但是可以通过-headers选项将http::geturl -headers http::geturl设置为大多数标题:

# Easiest to build the option as a dictionary
dict set opts X-Example-Header "fruitbats are mammals and this is nonsense"
dict set opts DNT "1 (Do Not Track Enabled)"

http::geturl $theurl -headers $opts

Almost everything can be set or overridden this way, and the things that can't are typically related to the management of the network connection itself (such as keep-alive management, chunking, compression) and are probably best left to the library in the first place, as HTTP/1.1 is a pretty complex protocol for something supposedly stateless. 几乎所有内容都可以通过这种方式设置或覆盖,并且通常与网络连接本身的管理(例如,保持活动管理,分块,压缩)无关的事物,最好留给数据库中的库。首先,因为HTTP / 1.1对于所谓的无状态协议来说是一个非常复杂的协议。

Note that options to http::geturl do not directly translate into request options. 请注意, http::geturl选项不会直接转换为请求选项。 It's a higher-level interface… 这是一个更高级别的界面…

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM