X-Accel-Redirect not passing Content-Type?

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

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.

and if you want to FORCE the header

use

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

the true will make sure it overrides

On Tue, Apr 7, 2009 at 5:14 PM, Michael S. [email protected]
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

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

On Wed, Apr 8, 2009 at 7:59 AM, Maxim D. [email protected] 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,

[email protected](B
Xia Q.
[email protected]

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

On Tue, Apr 7, 2009 at 3:34 PM, michael [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs