X-LiteSpeed-Location strange behaviour with Rails

andreas

Well-Known Member
#1
Hi,

I'm using X-LiteSpeed-Location to serve static files from a Rails app and noticed some strange behaviour:

This works:
Code:
        render_text ''
        headers['X-LiteSpeed-Location'] = "/myfile}"
This returns the correct file, but with status 404:
Code:
        render_text ''
        headers['X-LiteSpeed-Location'] = "/myfile}"
        headers.delete 'Status'
This returns the location header to the client, but with Status 404:
Code:
        render_text ''
        headers['Location'] = "/myfile}"
        headers.delete 'Status'
Andreas
 

andreas

Well-Known Member
#3
According to the documentation the backend must not send a status header if it wants to do an internal redirect. If I leave the default status that is set by render_text (=200) the "Location"-Header gets sent to the client.
 

mistwang

LiteSpeed Staff
#4
Set status code to 200 with "X-LiteSpeed-Location" should work.
Rails may change the status code to 3xx when "location" header was set, that will result in "Location" header being sent.

The 404 status code is because that 404 handler was used for Rails application, you can use rewrite rule to dispatch the request to Rails app handler. We will force the status code to 200 for 'X-LiteSpeed-Location' in 3.3 release.
 
Top