Forum: NGINX X-Accel-Redirect not passing Content-Type?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kon W. (Guest)
on 2009-04-08 01:57
(Received via mailing list)
I'm having an odd problem with x-accel-redirect when using PHP to
process the request:

Setting the headers in the php script:
header("Content-Type: blah/blah");

Result page header still comes through as:
Content-Type: text/html

Hence I am seeing .html tacked on to attachment filename downloads in
Chrome and Safari.

Is x-accel ignoring the Content-Type?

Cheers
Kon
Maxim D. (Guest)
on 2009-04-08 04:05
(Received via mailing list)
Hello!

On Tue, Apr 07, 2009 at 02:51:39PM -0700, Kon W. wrote:

> Chrome and Safari.
>
> Is x-accel ignoring the Content-Type?

No, it doesn't.  X-Accel-Redirect preserves Content-Type header
from original reply (the one which returned X-Accel-Redirect).

Check your php script actual reply to make sure it's actually
returns Content-Type header (actually as header, and no other
headers with same name).

Maxim D.
Michael S. (Guest)
on 2009-04-08 04:22
(Received via mailing list)
and if you want to FORCE the header

use

header('Content-Type: foo/bar', true);

the true will make sure it overrides
Kon W. (Guest)
on 2009-04-08 05:28
(Received via mailing list)
On Tue, Apr 7, 2009 at 5:14 PM, Michael S. 
<removed_email_address@domain.invalid>
wrote:
>>
>> No, it doesn't.  X-Accel-Redirect preserves Content-Type header
>> from original reply (the one which returned X-Accel-Redirect).
>>
>> Check your php script actual reply to make sure it's actually
>> returns Content-Type header (actually as header, and no other
>> headers with same name).

Thanks guys I will give it a shot :)

Cheers
Kon
michael (Guest)
on 2009-04-08 19:45
(Received via mailing list)
Are you setting Content-Type before X-Accel or after? I was just testing
X-Accel and ran into the same issue. Turns out I applied Content-Type
prior to X-Accel and it worked.

Per the documentation (or a mailing list post somewhere) X-Accel
*inherits* Content-Type, so I'd imagine if the server received an X-Accl
before Content-Type, the Content-Type would've been "determined"
already...

-Michael

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,897,899#msg-899
Kon W. (Guest)
on 2009-04-08 19:52
(Received via mailing list)
On Tue, Apr 7, 2009 at 3:34 PM, michael <removed_email_address@domain.invalid> 
wrote:
> Are you setting Content-Type before X-Accel or after? I was just testing X-Accel and ran 
into the same issue. Turns out I applied Content-Type prior to X-Accel and it worked.

Before, but the result is the same (text/html).

> Per the documentation (or a mailing list post somewhere) X-Accel *inherits* 
Content-Type, so I'd imagine if the server received an X-Accl before Content-Type, the 
Content-Type would've been "determined" already...

Correct, and if anything is echoed to the browser it is also
immutable. I've checked for both of these.

Cheers
Kon
Xia Q. (Guest)
on 2009-04-15 13:20
(Received via mailing list)
On Wed, Apr 8, 2009 at 7:59 AM, Maxim D. <removed_email_address@domain.invalid> 
wrote:
>
> No, it doesn't.  X-Accel-Redirect preserves Content-Type header
> from original reply (the one which returned X-Accel-Redirect).
>
> Check your php script actual reply to make sure it's actually
> returns Content-Type header (actually as header, and no other
> headers with same name).
>
> Maxim D.
>


Can nginx automaticly add Content-Type header when there is no
Content-Type in X-Accel-Redirect response?

If it could do, the backend CGI programs using X-Accel-Redirect will
feel better.


Regards,
--
$B2F@6A3(B
Xia Q.
removed_email_address@domain.invalid

Henny Youngman  - &quot;I told the doctor I broke my leg in two
places. He told me to quit going to those places.&quot; -
http://www.brainyquote.com/quotes/authors/h/henny_...
This topic is locked and can not be replied to.