lspai and RESTful routes

#1
Hi,

I (and others) are having a problem that seems to stem from using RESTful routes and the LS ruby api.

Before going any further, please note this is not a Rails issue as the scenario works perfectly using webbrick or mongrel in a script/server environment and works perfectly (important point here) under Litespeed if using Mongrels (production and development).

RESTful routes are not working ONLY when using Litespeed and the LSapi.

Scenario:

Simple Rails application with a scaffold_resource creation.

Using attachment_fu (in fact simply follow these instuctions: attachment_fu tutorial.)

First issue was that image_science was not working under the LSapi (remember it works perfectly under webbrick and LS with mongrels), I had to debug and then add:

ENV['HOME'] ||= '/home/onion/'
to my environment.rb file.

Ok, so now the simple app loads using LSapi.

Now uploading simply does not work there no errors in the rails logs, no errors in debug mode in Litespeed. Again, it works perfectly when using mongrels and Litespeed.

As there were no errors anywhere, I just played and eventually removed all RESTful references - routes were no longer:
upload_url(@upload)
I changed them to:
redirect_to :action => :show
Then everything worked using the LSAPI and continued to work with the mongrels/webbricks as they had all along.

As you can see, my thinking is that the LSAPI has issues with RESTful routes.

I probably can't give a great deal more information as it is easily replicated using the attachment_fu tutorial linked to above.

It will not work with LSAPI but works perfectly with LS + mongrels and with script/server running webbrick/mongrels.

Debain Etch (also fails on Ubuntu LTS)
Litespeed Ent 1-core v 3.2 (also fails on free v 3.2.1)
Rails 1.2.3
Ruby 1.8.5

Naturally, I would be delighted to supply more info if I can.

PickledOnion.
 

mistwang

LiteSpeed Staff
#2
Do you have a ready to use test application? If you do, please send it to bug @ litespeed ... , we will try to reproduce it in our lab.
 

mistwang

LiteSpeed Staff
#5
OK, I figured out the problem with the test application you sent me.
RESTful route is more picky on URL, request with URI "/mugshots" works, but request with URI "/mugshots/" does not, the old fashion route has no problem with it.

When LSWS receive a request with URI "/mugshots", it will check if directory or file "mugshots" exists under "public" directory, if a directory exists, LSWS redirect the request from "/mugshots" to "/mugshots/". In the test application, "mugshots" directory do exist, so you got the routing error.

Mongrel or WEBrick does not do the directory redirect, so that app works.

The 3.2.1 release has been updated to perform redirection more intelligently, do redirect if there is a index file under that directory, otherwise, return 404, this way the URI will be kept when handled by rails dispatcher.

So, please give updated 3.2.1 release a try.
 
#6
Mistwang and George,

I can confirm that it works perfectly under any RESTful routes I throw at it :)

Thanks very much for the work put in and the emails from George were very honest and encouraging.

Best Regards,

PickledOnion.
 
Last edited:
#7
Hi,

Just a quick one, have you got a link to the 3.2.1 Enterprise versions? I have downloaded and checked the free x86 version (3.2.1) but wanted to upgrade my x86_64 Enterprise version.

Many thanks.
 

palb

Well-Known Member
#14
palb - have you got an example as the new release solved all the RESTful route issues I had?

Thanks.
I know the thread actually deals with RESTful, and perhaps my problem didn't belong here in the first place. Sorry. I'm not into that yet. I'm just trying to get deeper into Rails in general. So I'm a kind of newbie, even though I worked in RoR for a while now. I was referring to a simple redirect_to that doesn't work. It just stops.
 

mistwang

LiteSpeed Staff
#15
Try upgrade ruby-lsapi, I have added a new release to rubyforge a while ago. That release should work well with redirect_to. We probably will not announce it officially, as we need to release a new release soon.
 
#17
I got the same problem

I tested a rails application using attachment_fu, and got this response in my browser when redirect after an upload:
--------------
Content-Type: text/html; charset=utf-8
Set-Cookie: _session_id=d72520c8e74984964c9d66634a8ac457; path=/
Status: 302 Found
Location: http://dev.sugarstats.com/meter_uploads/new?user_id=113
Cache-Control: no-cache
Content-Length: 121

<html><body>You are being <a href="http://dev.sugarstats.com/meter_uploads/new?user_id=113">redirected</a>.</body></html>
--------------

I remove the REST routes and the problem still happens, I upgraded to LiteSpeed 3.2.1 with no success. Currently I'm using:
LiteSpeed 3.2.1
ruby-lsapi 2.7

any idea?
 
#19
The problem has nothing to do with LiteSpeed. It's basically a problem with RubyInline library, which has a code that looks like :

Code:
  def self.rootdir
    env = ENV['INLINEDIR'] || ENV['HOME']

    if env.nil? then
      $stderr.puts "Define INLINEDIR or HOME in your environment and try again"
      exit 1
    end
 
Top