Guest User

Untitled

a guest
Jun 26th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. diff --git library/Zend/Http/Client/Adapter/Socket.php library/Zend/Http/Client/Adapter/Socket.php
  2. index e42f15c..3fd0d27 100755
  3. --- library/Zend/Http/Client/Adapter/Socket.php
  4. +++ library/Zend/Http/Client/Adapter/Socket.php
  5. @@ -320,7 +320,7 @@ class Socket implements HttpAdapter, Stream
  6. if ($statusCode == 100 || $statusCode == 101) return $this->read();
  7.  
  8. // Check headers to see what kind of connection / transfer encoding we have
  9. - $headers = $responseObj->headers()->toArray();
  10. + $headers = $responseObj->headers();
  11.  
  12. /**
  13. * Responses to HEAD requests and 204 or 304 responses are not expected
  14. @@ -330,16 +330,19 @@ class Socket implements HttpAdapter, Stream
  15. $this->method == \Zend\Http\Request::METHOD_HEAD) {
  16.  
  17. // Close the connection if requested to do so by the server
  18. - if (isset($headers['connection']) && $headers['connection'] == 'close') {
  19. + $connection = $headers->get('connection');
  20. + if ($connection !== false) && $connection->getFieldValue() == 'close') {
  21. $this->close();
  22. }
  23. return $response;
  24. }
  25.  
  26. // If we got a 'transfer-encoding: chunked' header
  27. - if (isset($headers['transfer-encoding'])) {
  28. + $transfer_encoding = $headers->get('transfer-encoding');
  29. + $content_length = $headers->get('content-length');
  30. + if ($transfer_encoding !== false) {
  31.  
  32. - if (strtolower($headers['transfer-encoding']) == 'chunked') {
  33. + if (strtolower($transfer_encoding->getFieldValue()) == 'chunked') {
  34.  
  35. do {
  36. $line = @fgets($this->socket);
  37. @@ -390,7 +393,7 @@ class Socket implements HttpAdapter, Stream
  38. } else {
  39. $this->close();
  40. throw new AdapterException\RuntimeException('Cannot handle "' .
  41. - $headers['transfer-encoding'] . '" transfer encoding');
  42. + $transfer_encoding->getFieldValue() . '" transfer encoding');
  43. }
  44.  
  45. // We automatically decode chunked-messages when writing to a stream
  46. @@ -399,15 +402,14 @@ class Socket implements HttpAdapter, Stream
  47. $response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $response);
  48. }
  49. // Else, if we got the content-length header, read this number of bytes
  50. - } elseif (isset($headers['content-length'])) {
  51. + } elseif ($content_length !== false) {
  52.  
  53. // If we got more than one Content-Length header (see ZF-9404) use
  54. // the last value sent
  55. - if (is_array($headers['content-length'])) {
  56. - $contentLength = $headers['content-length'][count($headers['content-length']) - 1];
  57. - } else {
  58. - $contentLength = $headers['content-length'];
  59. + if (is_array($content_length)) {
  60. + $content_length = $content_length[count($content_length) - 1];
  61. }
  62. + $contentLength = $content_length->getFieldValue();
  63.  
  64. $current_pos = ftell($this->socket);
  65. $chunk = '';
  66. @@ -460,7 +462,8 @@ class Socket implements HttpAdapter, Stream
  67. }
  68.  
  69. // Close the connection if requested to do so by the server
  70. - if (isset($headers['connection']) && $headers['connection'] == 'close') {
  71. + $connection = $headers->get('connection');
  72. + if ($connection !== false && $connection->getFieldValue() == 'close') {
  73. $this->close();
  74. }
Advertisement
Add Comment
Please, Sign In to add comment