GuzzleHttpHandlerEasyHandle

Represents a cURL easy handle and the data it populates.

Defined (1)

The class is defined in the following location(s).

/lib/Azure/GuzzleHttp/Handler/EasyHandle.php  
  1. final class EasyHandle 
  2. /** @var resource cURL resource */ 
  3. public $handle; 
  4.  
  5. /** @var StreamInterface Where data is being written */ 
  6. public $sink; 
  7.  
  8. /** @var array Received HTTP headers so far */ 
  9. public $headers = []; 
  10.  
  11. /** @var ResponseInterface Received response (if any) */ 
  12. public $response; 
  13.  
  14. /** @var RequestInterface Request being sent */ 
  15. public $request; 
  16.  
  17. /** @var array Request options */ 
  18. public $options = []; 
  19.  
  20. /** @var int cURL error number (if any) */ 
  21. public $errno = 0; 
  22.  
  23. /** @var \Exception Exception during on_headers (if any) */ 
  24. public $onHeadersException; 
  25.  
  26. /** 
  27. * Attach a response to the easy handle based on the received headers. 
  28. * @throws \RuntimeException if no headers have been received. 
  29. */ 
  30. public function createResponse() 
  31. if (empty($this->headers)) { 
  32. throw new \RuntimeException('No headers have been received'); 
  33.  
  34. // HTTP-version SP status-code SP reason-phrase 
  35. $startLine = explode(' ', array_shift($this->headers), 3); 
  36. $headers = \GuzzleHttp\headers_from_lines($this->headers); 
  37. $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); 
  38.  
  39. if (!empty($this->options['decode_content']) 
  40. && isset($normalizedKeys['content-encoding']) 
  41. ) { 
  42. $headers['x-encoded-content-encoding'] 
  43. = $headers[$normalizedKeys['content-encoding']]; 
  44. unset($headers[$normalizedKeys['content-encoding']]); 
  45. if (isset($normalizedKeys['content-length'])) { 
  46. $headers['x-encoded-content-length'] 
  47. = $headers[$normalizedKeys['content-length']]; 
  48.  
  49. $bodyLength = (int) $this->sink->getSize(); 
  50. if ($bodyLength) { 
  51. $headers[$normalizedKeys['content-length']] = $bodyLength; 
  52. } else { 
  53. unset($headers[$normalizedKeys['content-length']]); 
  54.  
  55. // Attach a response to the easy handle with the parsed headers. 
  56. $this->response = new Response( 
  57. $startLine[1],  
  58. $headers,  
  59. $this->sink,  
  60. substr($startLine[0], 5),  
  61. isset($startLine[2]) ? (string) $startLine[2] : null 
  62. ); 
  63.  
  64. public function __get($name) 
  65. $msg = $name === 'handle' 
  66. ? 'The EasyHandle has been released' 
  67. : 'Invalid property: ' . $name; 
  68. throw new \BadMethodCallException($msg);