I found some code `
require 'socket'
host = "download.thinkbroadband.com"
path = "/1GB.zip"
request = "GET #{path} HTTP/1.0\r\n\r\n"
socket = TCPSocket.open(host,80)
socket.print(request)
buffer = ""
while !buffer.match("\r\n\r\n") do
buffer += socket.read(1)
end
response = socket.read(100)
puts response`
How can I save the contents of the response as an attachment in a folder?
source
share