/**
  * Checks whether current connection may be reused or should be closed
  *
  * @param    boolean                 whether connection could be persistent
  *                                   in the first place
  * @param    Diglin_HTTP_Request2_Response  response object to check
  * @return   boolean
  */
 protected function canKeepAlive($requestKeepAlive, Diglin_HTTP_Request2_Response $response)
 {
     // Do not close socket on successful CONNECT request
     if (Diglin_HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && 200 <= $response->getStatus() && 300 > $response->getStatus()) {
         return true;
     }
     $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) || null !== $response->getHeader('content-length');
     $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || null === $response->getHeader('connection') && '1.1' == $response->getVersion();
     return $requestKeepAlive && $lengthKnown && $persistent;
 }