Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取错误404时,curl保持活动状态不工作 我用CURL加C++。 我在同一个句柄上执行所有请求,因此curl总是使用相同的连接。 但在服务器返回404并且下一个请求很快就会发出的情况下,curl会使用一个新的连接来执行。 有什么特别的原因吗? 在这种情况下,是否有办法将连接配置为一致_Curl - Fatal编程技术网

获取错误404时,curl保持活动状态不工作 我用CURL加C++。 我在同一个句柄上执行所有请求,因此curl总是使用相同的连接。 但在服务器返回404并且下一个请求很快就会发出的情况下,curl会使用一个新的连接来执行。 有什么特别的原因吗? 在这种情况下,是否有办法将连接配置为一致

获取错误404时,curl保持活动状态不工作 我用CURL加C++。 我在同一个句柄上执行所有请求,因此curl总是使用相同的连接。 但在服务器返回404并且下一个请求很快就会发出的情况下,curl会使用一个新的连接来执行。 有什么特别的原因吗? 在这种情况下,是否有办法将连接配置为一致,curl,Curl,我只想到一件事——查看404响应中包含的标题。服务器可能会发出一个连接:close头,即: # response example copied from http://php.net/manual/en/eventhttp.bind.php HTTP/1.1 404 Not Found Content-Type: text/html Date: Wed, 13 Mar 2013 04:14:41 GMT Content-Length: 149 Connection: close curl库可

我只想到一件事——查看404响应中包含的标题。服务器可能会发出一个
连接:close
头,即:

# response example copied from http://php.net/manual/en/eventhttp.bind.php

HTTP/1.1 404 Not Found
Content-Type: text/html
Date: Wed, 13 Mar 2013 04:14:41 GMT
Content-Length: 149
Connection: close

curl库可能会遵循以下原则:关闭连接的可能不是curl,而是web服务器。。。 我的观察结果是,如果响应代码为4xx,大多数web服务器都会关闭连接,而不考虑保持活动状态设置。例如:

$ telnet myserver 80
Trying myserver...
Connected to myserver.
Escape character is '^]'.
GET /foo HTTP/1.1
Host: myserver:80
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

HTTP/1.1 401 [ISS.0084.9004] Access Denied
Content-Type: text/html; charset=UTF-8
Connection: close
WWW-Authenticate: Basic realm="Integration Server", encoding="UTF-8"
Content-Length: 48

<h4>Access Denied</h4>
Connection closed by foreign host.
$telnet myserver 80
正在尝试我的服务器。。。
已连接到myserver。
转义字符为“^]”。
GET/foo HTTP/1.1
主机:myserver:80
连接:保持活力
缓存控制:最大年龄=0
接受:text/html、application/xhtml+xml、application/xml;q=0.9,*/*;q=0.8
HTTP/1.1 401[ISS.0084.9004]访问被拒绝
内容类型:text/html;字符集=UTF-8
连接:关闭
WWW-Authenticate:Basic realm=“集成服务器”,encoding=“UTF-8”
内容长度:48
拒绝访问
连接被外部主机关闭。

这里的提示是“连接被外部主机关闭。”

酷!我很高兴你发现了原因。你介意把这个问题标记为已回答/已接受/已解决吗?:)