lspai and RESTful routes

Discussion in 'Ruby/Rails' started by PickledOnion, Aug 2, 2007.

  1. PickledOnion

    PickledOnion New Member

    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:

    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:
    I changed them to:
    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.
  2. mistwang

    mistwang LiteSpeed Staff

    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.
  3. PickledOnion

    PickledOnion New Member

    Thanks,

    email on the way
  4. mistwang

    mistwang LiteSpeed Staff

    Please make sure to use our full domain name, SPAM robots are crazy collecting email addresses. ;)
  5. mistwang

    mistwang LiteSpeed Staff

    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. PickledOnion

    PickledOnion New Member

    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: Aug 5, 2007
  7. PickledOnion

    PickledOnion New Member

    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.
  8. mistwang

    mistwang LiteSpeed Staff

    Please wait for our official release.
  9. PickledOnion

    PickledOnion New Member

    No worries.

    Thanks again for the work :)
  10. palb

    palb New Member

    I have the same problem. I get the impression that there is a 3.2.1 Std to download but not on the download page, or?
  11. mistwang

    mistwang LiteSpeed Staff

    3.2.1. has been released.
  12. palb

    palb New Member

    The problem persist.
  13. PickledOnion

    PickledOnion New Member

    palb - have you got an example as the new release solved all the RESTful route issues I had?

    Thanks.
  14. palb

    palb New Member

    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.
  15. mistwang

    mistwang LiteSpeed Staff

    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.
  16. palb

    palb New Member

    Ok. I'll try that. :)
  17. edgar

    edgar New Member

    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?
  18. edgar

    edgar New Member

    My fault

    I wasn't using the right dispatch.lsapi for ruby_lsapi 2.7
  19. pratiknaik

    pratiknaik New Member

    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
    

Share This Page