Skip to content

Instantly share code, notes, and snippets.

@ivey
Created October 29, 2008 02:43
Show Gist options
  • Save ivey/20596 to your computer and use it in GitHub Desktop.
Save ivey/20596 to your computer and use it in GitHub Desktop.
def HTTP.get_truncated_response(uri_or_host, path = nil, port = nil, &block)
range = { 'Range' => "bytes=0-1000"}
if path
host = uri_or_host
new(host, port || HTTP.default_port).start {|http|
return http.request_get(path, range, &block)
}
else
uri = uri_or_host
new(uri.host, uri.port).start {|http|
return http.request_get(uri.request_uri, range, &block)
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment