2009-07-17 5 views
3

Ich habe einige Code `Herunterladen von großen Dateien (~ 40 MB) und Speichern als Anlagen mit Büroklammer

gefunden
require 'socket' 
host = "download.thinkbroadband.com" 
path = "/1GB.zip" # get 1gb sample file 
request = "GET #{path} HTTP/1.0\r\n\r\n" 
socket = TCPSocket.open(host,80) 
socket.print(request) 

# find beginning of response body 
buffer = "" 
while !buffer.match("\r\n\r\n") do 
    buffer += socket.read(1) 
end 

response = socket.read(100) #read first 100 bytes of body 
puts response` 

Wie ich den Inhalt der Antwort als Anhang in Büroklammer speichern kann?

Antwort

Verwandte Themen