Error on multiple POST between two rails

I am trying to do multi-page write from one rails application to another using the following code:

require 'rest_client'
RestClient.post 'http://localhost:3000/users', { "user[fist_name]" => "foo", "user[profile_image]" => File.new('/test.png') })

      

My client application is throwing a timeout exception and the server is throwing the exception shown below.

Fri Sep 18 13:39:31 -0700 2009: Error reading HTTP body: #<RuntimeError: Socket read returned insufficient data: 281>
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/http_request.rb:107:in `read_socket'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/http_request.rb:77:in `read_body'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel/http_request.rb:55:in `initialize'

      

The Rails server accepts multipart requests from the browser and regular (not multipart) requests from the Rails client.

PS: I have the same exception when I used technoveenie_rest-client in my client application.

PPS: I am using Rails 2.3.2, ruby ​​1.8.6, Mongrel on Windows XP.

+2


source to share


1 answer


I think you need to increase the timeout on your server.

When you look at the source code:



    def read_socket(len)
      if !@socket.closed?
        data = @socket.read(len)
        if !data
          raise "Socket read return nil"
        elsif data.length != len
          raise "Socket read returned insufficient data: #{data.length}"
        else
          data
        end
      else
        raise "Socket already closed when reading."
      end
    end

      

You will see that this post comes from checking if the content length is not equal to the length of the rendered body in post-header.

0


source







All Articles