Browse files

Merge branch 'hotfix/issue-#3033' of git://github.com/Ocramius/zf2 in…

…to hotfix/3049
  • Loading branch information...
2 parents 8cbf235 + 81ced37 commit b7a6d104c8b46eaf745c760fa0a83f3dbd1c157d @weierophinney weierophinney committed Dec 10, 2012
View
2 library/Zend/Http/Client/Adapter/Socket.php
@@ -360,7 +360,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
ErrorHandler::start();
$test = fwrite($this->socket, $request);
$error = ErrorHandler::stop();
- if (!$test) {
+ if (false === $test) {
throw new AdapterException\RuntimeException('Error writing request to server', 0, $error);
}
View
12 tests/ZendTest/Http/Client/SocketTest.php
@@ -11,6 +11,7 @@
namespace ZendTest\Http\Client;
use Zend\Http\Client\Adapter;
+use Zend\Uri\Uri;
/**
* This Testsuite includes all Zend_Http_Client that require a working web
@@ -250,6 +251,17 @@ public function testMultibyteChunkedResponseZF6218()
}
/**
+ * Verifies that writing on a socket is considered valid even if 0 bytes
+ * were written.
+ */
+ public function testAllowsZeroWrittenBytes()
+ {
+ $this->_adapter->connect('localhost');
+ require_once __DIR__ . '/_files/fwrite.php';
+ $this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', array(), 'test body');
+ }
+
+ /**
* Data Providers
*/
View
22 tests/ZendTest/Http/Client/_files/fwrite.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Http
+ */
+
+namespace Zend\Http\Client\Adapter;
+
+/**
+ * This is a stub for PHP's `fwrite` function. It
+ * allows us to check that a write operation to a
+ * socket producing a returned "0 bytes" written
+ * is actually valid.
+ */
+function fwrite($socket, $request)
+{
+ return 0;
+}

0 comments on commit b7a6d10

Please sign in to comment.