From: Francis Cianfrocca Date: 2006-12-30T02:51:05+09:00 Subject: Re: how to properly format data when using TCPSocket.send() ------=_Part_92340_18709653.1167414663534 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/29/06, Nathan Taylor wrote: > > It would be greatly appreciated if someone would clue me in to what I am > doing wrong here. I am trying to send this data below to httpd(Apache) > however I am receiving a http response code of 400 (bad request). > Apache is logging "request failed: error reading the headers" in > error_log, however if I replace the \r\n with \x0d\x0a and send this > through netcat to Apache I get the proper response code I am looking > for. > > > http_socket = TCPSocket.new("#{i}", 80); http_socket.send("PUT > /puttest.html HTTP/1.0\r\nHost: #{i}\r\nConnection: > close\r\nContent-type: text/html\r\nContent-Length: > 309\r\nSee Spot Run!See Spot > Run!See Spot Run!\r\n\r\n", 0) > > Thank you, > > Nathan > > -- > Posted via http://www.ruby-forum.com/. > > Why are you putting HTML content in the header block? Try putting it after the \r\n\r\n that terminates the header. Also, you want to get the content length value correct. If that still doesn't work, you could try POST instead of PUT (except you already implied that PUT works correctly on this Apache server with netcat). ------=_Part_92340_18709653.1167414663534--