cURL PUT请求挂起

亚历克西斯·科特(Alexis Cote)

所以这是我的问题。

我正在使用curl通过HTTP访问我的CouchDB。我最近将WAMP更新为PHP 5.6.16和Apache 2.4.17随附的WAMP 3 64位。因此,自此次升级以来,我发现我无法再执行PUT请求了。

环保

  1. PHP 5.6.16
  2. 阿帕奇2.4.17
  3. Windows 10 64位
  4. Wamp 3 64位

卷曲-版本

 curl 7.49.1 (x86_64-pc-win32) libcurl/7.49.1 OpenSSL/1.0.2h nghttp2/1.11.1
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM SSL HTTP2

执行代码

因此,当我执行此命令时:

<?php
$table="testname";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://localhost:5984/' . $table);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, 'validUser:validPass');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'Content-type: application/json',
 'Accept: */*'
));

$response = curl_exec($ch);
curl_close($ch);

echo $response;

我从服务器得到快速响应。

然后,我尝试创建一个数据库:

<?php
$table = "testname";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://localhost:5984/' . $table);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, 'validUser:validPass');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 'Content-type: application/json',
 'Accept: */*'
));

$response = curl_exec($ch);
curl_close($ch);

echo $response;

问题

因此,当我执行此代码时,请求将挂在curl_exec上。奇怪的是,超时后,CouchDB会收到请求,但不会给出响应。看来我的“放置”请求堆积在缓冲区中,它们正在等待执行。

详细的卷发输出

* Hostname in DNS cache was stale, zapped
*   Trying ::1...
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5984 (#0)
* Server auth using Basic with user 'validUser'
> PUT /customers HTTP/1.1
Host: localhost:5984
Authorization: Basic dGVzdEFkbWluOnRlc3RQYXNzd29yZA==
Content-type: application/json
Accept: */*

* Operation timed out after 10000 milliseconds with 0 bytes received
* Closing connection 0

提示

-我尝试安装SSL证书,但似乎没有用。仍然安装此证书会导致问题吗?-我可以在Atom编辑器上使用REST客户端执行PUT请求,而不会出现问题。-我的内部网络路由似乎有问题。我说这是因为它影响了PHP-Curl以及Curl CLI。另外,我能够执行GET请求,但PUT请求无缘无故地像“挂起”,并且在发生超时时被CouchDB“接受”。就像我要发送长时间的轮询请求一样。

已经测试了什么

  1. 在命令行上执行相同的命令->相同的结果
  2. 成功在我的Atom编辑器上尝试REST客户端
  3. 我的一个朋友尝试成功远程访问我的数据库(所以CouchDB似乎不是问题)
亚历克西斯·科特(Alexis Cote)

即使我在禁用防火墙的情况下进行测试,卸载防病毒软件(Bitdefender Total Security 2016)也解决了我的问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章