Re: Headers in fpassthru() output [message #176943 is a reply to message #176940] |
Wed, 08 February 2012 09:10 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma:
|
Senior Member |
|
|
El 07/02/2012 17:36, Michael T. Davis escribió/wrote:
>> I don't know for sure what manual page you are quoting (you just point
>> to the PHP site) but the full quote at the page for the HTTP wrapper [1] is:
>>
>> «The stream allows access to the body of the resource; the headers are
>> stored in the $http_response_header variable.»
>>
>> ... and that's exactly what you are doing: printing the values of the
>> $http_response_header variable [2].
>>
>> [1] http://es2.php.net/manual/en/wrappers.http.php
>> [2] http://es2.php.net/manual/en/reserved.variables.httpresponseheader.php
>
> I'm referencing the English version of the documentation that you
> are citing.
Well, the documentation I'm citing is already in English :)
>> Neither http://es.php.net/manual/en/function.fopen.php nor
>> http://es.php.net/fpassthru claim that $http_response_header should not
>> get populated...
>
> I didn't claim that $http_response_header was invalid. As I
> mentioned in the parenthetical at the end of the original post, I'm trying
> to serve the JPEG image of a network Webcam from the host where I have the
> PHP script, in order to make it appear as if the JPEG image comes from the
> PHP-running host. This means I need to send the headers that come from
> the response of the Webcam to the browser. I can certainly leverage
> $http_response_header and push the contents to the broswer, but if I do
> that--given the behavior I'm seeing--it seems I would still need to parse
> the headers from the fopen call and "drop them on the floor" before sending
> the "actual" body/image of what comes from the Webcam. If I'm going to
> parse the headers, I figured I might as well do something with them, which
> is why the work-around doesn't call on $http_response_header.
I think you already got it, according to your latest post in this
thread. You were probably getting confused by some CGI modules that send
the raw output as generated by the script, so you have to start printing
the HTTP headers plus a blank line. It's not the case in PHP: the output
of echo statements always goes to the response body.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|