Internal Redirect w/ Rails

#1
I am trying to serve some files in the most secure fashion using Litespeed's INternal Redirect that I read about here: http://litespeedtech.com/support/wiki/doku.php?id=litespeed:wiki:feature:internal_redirect

When from my controller I send:

headers['Location'] = "/path/to/file"

It doesn't seem to flow through to the web server as I am reading through the logs. Does anyone have any experience with this... or perhaps some ruby code that may show an example of this.

Thanks in advance!
 
#3
Thanks for the reply:

Please help me verify that I am doing the right thing. The document root of my rails app is of course the public folder. In the public folder I have a folder called products and inside that folder is a file called test.mp3.

With that information in mind here is the statement I am not using in my controller: headers['X-LiteSpeed-Location'] = "/products/test.mp3"

Using "X-LiteSpeed-Location" seems to have got me further than just 'Location' did... I am now seeing some information in the log that shows the URL to the file is at least being passed through. But the file is still not coming out on the back end. Here is a snippet from my log in the area of concern.

Please let me know if everything looks kosher here:

2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] process packet header 8 bytes
2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] process response stream 921 bytes, packet left: 921
2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] response header finished!
2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::continueWrite()...
2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] write resumed!
2007-12-03 13:13:41.063 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] process packet header 0 bytes
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::handleEvents() events=4!
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::suspendWrite()...
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] redirect to:
URI=[/products/test.mp3],
QueryString=[]
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Find context with URI: [/], location: [/u/apps/guifx_store/releases/20071202215503/public/]
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] processContextPath() return 0
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpExtConnector::cleanUp() ...
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] abort request...
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] [LSAPI] send abort packet!
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] release ExtProcessor!
2007-12-03 13:13:41.064 [DEBUG] [idle] [ExtConn] close()
2007-12-03 13:13:41.064 [DEBUG] [uds://tmp/lshttpd/guifx_store:_.sock] add recycled connection to connection pool!

A few lines after the line where it shows the redirect_to: and the URI being effectively set to /products/text.mp3 it says the request was aborted... is this where my new problem lies?
 

mistwang

LiteSpeed Staff
#4
It is normal I think, LSWS just abort the Rails request after receiving the redirect in header. Are there more logging entry for 64.135.18.66:55928-0 after the request aborted.
 
#5
In addition to the "X-LiteSpeed-Location" header do I need to send any additional headers as I had stated before the files aren't downloading.. they seem to just be appearing in the window.

Here is the rest of what was logged on that request:

2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] readyCacheData() return 0
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Written to client: 327
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Written to client: 10136
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] m_pHandler->onWrite() return 1
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::continueWrite()...
2007-12-03 13:13:41.064 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] write resumed!
2007-12-03 13:13:41.143 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::handleEvents() events=4!
2007-12-03 13:13:41.143 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Written to client: 4344
2007-12-03 13:13:41.143 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] m_pHandler->onWrite() return 1
2007-12-03 13:13:41.219 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::handleEvents() events=4!
2007-12-03 13:13:41.219 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Written to client: 13032
2007-12-03 13:13:41.219 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] m_pHandler->onWrite() return 1
2007-12-03 13:13:41.245 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::handleEvents() events=1!
2007-12-03 13:13:41.245 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::suspendRead()...
2007-12-03 13:13:41.267 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] HttpIOLink::handleEvents() events=24!
2007-12-03 13:13:41.267 [DEBUG] [64.135.18.66:55928-0#guifx_store:lsapi] Close socket ...
2007-12-03 13:13:42.310 [DEBUG] [64.135.18.66:55924-1] Keep-alive timeout, close!
2007-12-03 13:13:42.311 [DEBUG] [64.135.18.66:55924-1] Shutting down out-bound socket ...
2007-12-03 13:13:43.383 [DEBUG] [64.135.18.66:55924-1] Shutdown time out!
2007-12-03 13:13:43.383 [DEBUG] [64.135.18.66:55924-1] Close socket ...
2007-12-03 13:14:19.011 [DEBUG] [idle] Idle connection timed out, close!
2007-12-03 13:14:19.011 [DEBUG] [idle] [ExtConn] close()
2007-12-03 13:19:20.087 [DEBUG] Remove pid: 3136
 

mistwang

LiteSpeed Staff
#6
You can try the request from command line tool like "lynx -mime_header <url>", or with FireFox module, live-header or firbug. I think the Content-type has not been set properly.

Maybe the rails app set "content-type" to "text/html", and the Content-Type has not been overridden properly for the new file, you can try set it explicitly in the rails application to match the mime-type for the file.
 
#7
Great, thanks so much for the help...

Is there some type of 'vague' content-type.... I will be serving both .zip files and .exe files to my customers.
 
Top