PHP:将所有行写入流

I wanted to write a quick http response parser. I'm not counting on PECL to be installed so the headers I'm doing on my own. The HTML portion I'll be using the DomDocument. The headers will be in an associative array.

The issue is that fwrite($response, shell_exec($request)); only appears to place the first response line into the stream.

I thought streams would be the things to use because I wanted to go line by line when reading. It is created with: $response = fopen("php://temp", "r+b"); Once live, written by the fwrite() call above. For testing, its fwrite($response, file_get_contents("/*HTML+HDRS_FILE*/")); Either produces the same result. I parse out the status code and can go no further.

$request is a call to curl. All that works fine. My test file has all the headers I expected. feof($response) returns 1 after one call to stream_get_line()

Turns out to be an example of reading the documentation too quickly, assumptions, and not using familiar functions (like fgets()). Those combined led me to believe that the delimiter was an optional parameter for stream_get_line() and newlines would be the default.

Not the case. The delimiter must be specified. So confident was I that I didn't even echo stream_get_contents(). That would've gotten me to the right place sooner.