Rails: response 404

Discussion in 'Bug Reports' started by andreas, Jan 15, 2007.

  1. andreas

    andreas Well-Known Member


    I have a really weird problem with Rails + Litespeed (2.2.6) + LSAPI (1.12). I migrated a very small app from lighttpd/fastcgi to LSAPI. Since then, I have the following problem:

    The app generates a PDF file, sets the content type to application/pdf, and returns the file. The Rails log reports a status 200. The lsws log reports status 404, and the client gets a 404 but the correct content.

    This is the Rails log entry:
    Completed in 0.53705 (1 reqs/sec) | Rendering: 0.04865 (9%) | DB: 0.48415 (90%) | 200 OK [https://xxx/orders/label/1111]
    These are the headers that the client gets:
    # wget --http-user=xxx --http-password=xxx --no-check-certificate -S https://xxx/orders/label/1111
    --21:13:42--  https://xxx/orders/label/1111
               => `1111'
    Resolving xxx
    Connecting to xxx... connected.
    HTTP request sent, awaiting response... 
      HTTP/1.0 404 Not Found
      Server: LiteSpeed
      Date: Mon, 15 Jan 2007 20:13:42 GMT
      Connection: close
      WWW-Authenticate: Basic realm="xxx"
    21:13:42 ERROR 404: Not Found.
    As you can see:
    1) the status code is 404
    2) the content-type header is missing

    BUT: the content gets delivered.
  2. mistwang

    mistwang LiteSpeed Staff

    In your rails application, you need to set header "status: 200\n".
  3. andreas

    andreas Well-Known Member

    200 is the default status, I dumped the header hash to confirm it:

    @headers={"Status"=>"200", ...
  4. mistwang

    mistwang LiteSpeed Staff

  5. andreas

    andreas Well-Known Member

    No bug.

    The problem was caused by a library that was printing debug information to stdout. Appearently stdout is redirected to the webserver, so this lead to the described problem.
  6. mistwang

    mistwang LiteSpeed Staff

    Thank you for the update. That's something what I expected. :)

Share This Page