zendframework/zf2 — pull request #6027 by alexhenrie (2014-03-23 09:41:23+00:00)
Title: Allow empty response strings in \Zend\Http\Response::fromStream

If the [explode](http://us2.php.net/explode) function is only passed 2 parameters, it will always return an array of size 1 or greater, which means that $headerComplete will be set to true whether or not there was actually any data in the response string. This causes \Zend\Http\Response::fromStream to fail without reason.

For example, if you wanted to proxy the English Wikipedia's main page, you might say:

```
public function indexAction() {
$socket = fsockopen('en.wikipedia.org', 80);
fwrite($socket, "GET /wiki/Main_Page\nHost: en.wikipedia.org\n\n");
$ret = \Zend\Http\Response\Stream::fromStream('', $socket);
return $ret;
}
```

In the current version of Zend Framework, this example results in the following error:

```
Zend\Http\Exception\InvalidArgumentException
vendor/zendframework/zendframework/library/Zend/Http/Response.php:184
A valid response status line was not found in the provided string
```

There is no good reason to produce an error here. With my attached code, the request is honored and processed normally.