From: Richard Conroy Date: 2007-10-24T01:29:50+09:00 Subject: Re: How to send a file from the http client to the server? On 10/23/07, Abir B. wrote: > Richard Conroy wrote: > > Abir, > > Or are you using something non-Ruby like curl, and need to know exactly > > how you > > pad out the HTTP Header? > > I used Ruby (Mongrel) to code the server, and for the client I must use > ruby because the file will be generated by the client and then sent to > the server, but I'm confused between httpclient, net/http, open-uri ... > I don't know the best choice wich respond to my needs. I feel your pain. I don't know httpclient directly, but net/http is very low level and difficult to work with when you just want to get stuff done, or validate a server design. Also open-uri, which is super-friendly to use, can't use POST, which is a bit of a deal breaker. AFAIK there isn't a solid contender in the Ruby Http Library space. Also, you are sending up a file. As far as your Http Client is concerned, it can ignore the 'file' input from the form. You might want to take a look at some alternative HttpClients (e.g. Hpricot, WATIR, WWW::Mechanize, or look at some open source application specific http clients (like the 2 clients that are used to connect Ruby with Amazon's S3 service). Alternatively the O'Reilly RESTful Web Services book, has some advice on this, and the authors made some modifications to open-uri to support all the HTTP verbs: just gem install rest-open-uri, and you might get open-uri friendliness without the deal breakers.