fsockopen https冻结在fgets上

| 我尝试通过PHP fsockopen连接到服务器,以最初获取基本身份验证的cookie,然后持久连接到响应的Location标头中定义的流服务器。 问题是我的代码在fgets上冻结,并且从未收到来自目标服务器的任何响应数据。我正在通过Amazon EC2实例上端口443上的https连接。服务器可以通过我的服务器终端中的curl或我的chome浏览器正常连接。
  $this->conn = fsockopen(\'ssl://[destination_server]\', 443, $errNo, $errStr, $this->connectTimeout);
  stream_set_blocking($this->conn, 1);

  fwrite($this->conn, \"GET \" . $urlParts[\'path\'] . \" HTTP/1.0\\r\\n\");
  fwrite($this->conn, \"Host: \" . $urlParts[\'host\'] . \"\\r\\n\");
  fwrite($this->conn, \"Content-type: application/x-www-form-urlencoded\\r\\n\");
  fwrite($this->conn, \"Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\");    
  fwrite($this->conn, \'Authorization: Basic \' . $authCredentials . \"\\r\\n\");
  fwrite($this->conn, \'User-Agent: \' . self::USER_AGENT . \"\\r\\n\");

  list($httpVer, $httpCode, $httpMessage) = preg_split(\'/\\s+/\', trim(fgets($this->conn, 1024)), 3);

  //code never gets here!!!
有什么想法吗?     
已邀请:
我通过添加标题解决了这个问题:\“ Connection:Close \\ r \\ n \\ r \\ n \”。 对Cookie的初始请求返回302重定向代码,并且将位于打开的连接上,除非您传递该标头。 不幸的是,这条小路让我难过了一段时间。     

要回复问题请先登录注册