简体   繁体   English

如何从php CURL请求中删除标头“ Proxy-Connection:Keep-Alive”?

[英]How can I remove the header “Proxy-Connection: Keep-Alive” from a php CURL request?

I'm am trying to access a webpage using an HTTP proxy with curl and php. 我正在尝试使用带有curl和php的HTTP代理访问网页。 I want to make the request look as close as possible to a real browser, however when I send the GET request through CURL, it sends the header "Proxy-Connection: Keep-Alive" even when I haven't specified it. 我想使请求看起来尽可能接近真实的浏览器,但是当我通过CURL发送GET请求时,即使没有指定,它也会发送标头“ Proxy-Connection:Keep-Alive”。 How can I remove "Proxy-Connection: Keep-Alive" from the sent headers? 如何从发送的标题中删除“代理连接:保持活动”?

尝试使用-H参数而不为要删除的内部标头指定值:

curl -H "Proxy-Connection:" http://somehost

If you're using recent version of curl, you should use --proxy-header option: 如果您使用的是最新版本的curl, 则应使用 --proxy-header选项:

curl --proxy-header "Proxy-Connection:" http://somehost

This is CURLOPT_PROXYHEADER option in php which available starting from php 7.0.7. 这是php中的CURLOPT_PROXYHEADER选项,从PHP 7.0.7开始可用。

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

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