Permalink
Browse files

Merge branch 'hotfix/3049'

Fixes #3033
Close #3049
  • Loading branch information...
2 parents cf7d69e + 69b18c8 commit 65cf549f5753054544882ea572b29d288e8d934a @weierophinney weierophinney committed Dec 10, 2012
@@ -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);
}
@@ -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
*/
@@ -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 65cf549

Please sign in to comment.