X-Accel-Redirect not passing Content-Type?


#1

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


#2

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.


#3

and if you want to FORCE the header

use

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

the true will make sure it overrides


#4

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 :slight_smile:

Cheers
Kon


#5

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


#6

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,

e$B2F@6A3e(B
Xia Q.
removed_email_address@domain.invalid

Henny Youngman - "I told the doctor I broke my leg in two
places. He told me to quit going to those places." -
http://www.brainyquote.com/quotes/authors/h/henny_youngman.html


#7

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