C
Chris McMahon
Sorry if this gets double-posted:
Is there any way to get net/http to follow a 302 redirect?
title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://bar.foo.com:22010">here</
a>.</p>
###################
require 'net/http'
uri = 'http://foo.bar.com:22010'
unless uri = (URI.parse(ARGV.shift) rescue nil)
puts "Usage: #$0 <url>"
exit
end
puts "Sending PUT #{uri.request_uri} to #{uri.host}:#{uri.port}"
Net::HTTP.start(uri.host, uri.port) do |http|
headers = {'Content-Type' => 'text/plain; charset=utf-8'}
put_data = "put payload"
response = http.send_request('PUT', uri.request_uri, put_data,
headers)
puts "Response #{response.code} #{response.message}:
#{response.body}"
end
Is there any way to get net/http to follow a 302 redirect?
title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://bar.foo.com:22010">here</
a>.</p>
###################
require 'net/http'
uri = 'http://foo.bar.com:22010'
unless uri = (URI.parse(ARGV.shift) rescue nil)
puts "Usage: #$0 <url>"
exit
end
puts "Sending PUT #{uri.request_uri} to #{uri.host}:#{uri.port}"
Net::HTTP.start(uri.host, uri.port) do |http|
headers = {'Content-Type' => 'text/plain; charset=utf-8'}
put_data = "put payload"
response = http.send_request('PUT', uri.request_uri, put_data,
headers)
puts "Response #{response.code} #{response.message}:
#{response.body}"
end