On Dec 29, 2006, at 09:44, 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\n<html><head>See Spot Run!</head><title>See Spot > Run!</title><body>See Spot Run!</body></html>\r\n\r\n", 0) the net/http library handles this much better: require 'net/http' data = "<html><head>See Spot Run!</head><title>See Spot Run!</ title><body>See Spot Run!</body></html>" uri = URI.parse 'http://example.com/puttest.html' Net::HTTP.start uri.host, uri.port do |http| http.post uri.request_uri, data, 'Content-Type' => 'text/html' end -- Eric Hodel - drbrain / segment7.net - http://blog.segment7.net I LIT YOUR GEM ON FIRE!