LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   Ruby/Rails (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=20)
-   -   Ajax call is not interpreted as an ajax call (http://www.litespeedtech.com/support/forum/showthread.php?t=889)

thbar 02-26-2007 12:29 AM

Ajax call is not interpreted as an ajax call
 
Hi!

I'm having an issue which only appears with LSWS. I have a rails 1.2 app on LSWS 2.2.2 with LSAPI (which also hosts another rails app). Everything works perfectly fine, except Ajax calls : they all render non-ajax versions of the pages. I have the feeling that the application does not receive one of the headers (maybe X-Requested-With).

Here are the typical headers sent by the client on these requests:

Request Headers
Host myapp.mydomain.fr
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
Accept text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
X-Prototype-Version 1.5.0
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Content-Length 0
Cookie ....
Pragma no-cache
Cache-Control no-cache


Did anyone meet this issue ?

Is there something to configure at LSWS level with regards to the headers ?

best regards

Thibaut

mistwang 02-26-2007 10:49 AM

Our rails easy configuration uses 404 handler to forward requests to backend Rails application, if there are both AJAX and non-AJAX version of pages for the same URL, the static version of the page will be served for sure.

To workaround this, you can use a vhost level rewrite rule to detect AJAX call by testing existence of "X-Requested-With" header.
Something like,

Code:

RewriteCond %{HTTP:X-Requested-With} !^$
RewriteRule  ^/  /dispatch.lsapi  [L]


thbar 02-26-2007 03:38 PM

I've decided to try an upgrade and it worked! (without the rewriting work-around).

After upgrading from 2.2.2 to 2.2.6, and installing ruby-lsapi 2.0, everything is working fine.

Thanks for your work

Thibaut


All times are GMT -7. The time now is 06:50 PM.