From: Jim Menard Date: 2001-12-22T13:15:00+09:00 Subject: [ruby-talk:29288] Re: HTTP POST Minero Aoki writes: > In mail "[ruby-talk:29282] Re: HTTP POST" > Jim Menard wrote: > > > servlet-engine => Tomcat Web Server/3.2.3 (JSP 1.1; Servlet 2.2; Java 1.3.1-internal; FreeBSD 4.4-STABLE i386; java.vendor=Sun Microsystems Inc.) > > Hmm. I've heard that Tomcat always requires Content-Type. > Try this: > > Net::HTTP.start(HOST, PORT) {|http| > res = http.post(PATH, 'Content-Type' => 'x-www-form-urlencoded') > p res.body > } > I have POST data to send as well, so instead of your code I tried this: hash = {'Content-Type' => 'x-www-form-urlencoded'} resp = http.post2(PING_SERVER_URL, data, hash) (where data contains POST request data like "a=b&c=d"). The results were the same: the body is empty. Everything is the same if I use post() instead of post2() (and add a comma after the "resp"): hash = {'Content-Type' => 'x-www-form-urlencoded'} resp , = http.post(PING_SERVER_URL, data, hash) Note from my previous email that the value of response['Content-Length'] is nil. Could that be the problem? > FYI: > In 1.7, net/http automatically set Content-Type to x-www-form-urlencoded. > I'll also backport it to 1.6 soon. > > -- Minero Aoki Again, thank you for all your help. Jim -- Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "The reason why there is no good commercial Java develoment environment is that the only folks that are good enough to write one all use EMACS." -- Unknown, on comp.lang.java.programmer