Background: I'm writing a custom PHP stream wrapper that handles HTTP request. It should act exactly as PHPs built-in HTTP wrapper, but provide some additional functionality to aid in writing unit test. @ShawnMcKenzie: I'll try to answer your questions as best I can. Q1. $http_response_header is set with the response headers from the other end, how/why would you populate them? A1. How: Normally the built-in http wrapper that PHP provides handles setting the $http_response_header variable when you call fopen. My wrapper replaces the built-in http wrapper, so it would be responsible for setting that variable. A2. Why: If someone were to use my stream wrapper, they would expect that headers are available through the usual means. It would be the job of my script to make sure that is the case. Q2. If your script is sending a request or response then you issue headers with the header() function or with parameters to the function or class that you are using etc. A2. My script does not send request. It actually fulfills an HTTP request when you call fopen or file_get_contents. It processes the request using a socket. Upon success, fopen is returned a handle to be used with fread, or in the case of file_get_contents, then the response body is returned. Again, my script is a stream wrapper for the HTTP protocol, which substitutes the built-in PHP http stream wrapper. Q3. How are you issuing requests/responses? A3. My script does not issue request. To use my script, you must register my script as the http wrapper using stream_register_wrapper function. Then you would use fopen/file_get_contents to send a request. When say file_get_contents is called, them my script will be called up to fulfill the request to the server, and supply the response. These links may also provide some insight: see here: * Where $http_response_header get set in PHP source: https://github.com/php/php-src/blob/88ca46d92bc1c426e7c7f7313f0fd2b7dcc33cf6/ext/standard/http_fopen_wrapper.c#L661 * Stream wrapper intro: http://php.net/manual/en/class.streamwrapper.php * Example stream wrapper class: http://php.net/manual/en/stream.streamwrapper.example-1.php Khalifah (Cah - lee - fah) Shabazz On Wed, Nov 26, 2014 at 9:49 AM, Shawn McKenzie <shawn@xxxxxxxxxxxxx> wrote: > $http_response_header is set with the response headers from the other end, > how/why would you populate them? If your script is send a request or > reponse then you issue headers with the header() function or with parameters > to the function or class that you are using etc. How are you issuing > requests/responses? > > -Shawn > > On Wed, Nov 26, 2014 at 8:00 AM, Khalifah Shabazz <shabazzk@xxxxxxxxx> > wrote: >> >> I wrote a custom HTTP wrapper, but I've hit a snag. I do not know how >> to populate the $http_response_header variable. So my questions are: >> >> 1. Is it even possible to set $http_response_header from a custom PHP >> Stream wrapper? >> 2. Is there documentation on how to set it? >> 3. If there is no official way to set it, then is there a work-a-round >> way to set $http_response_header? >> >> PHP doc on $http_response_header variable: >> http://php.net/manual/en/reserved.variables.httpresponseheader.php >> >> -- >> Khalifah (Ca - lee - fah) Shabazz >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php