Class: PuppetForgeServer::Http::HttpClient
- Inherits:
-
Object
- Object
- PuppetForgeServer::Http::HttpClient
- Defined in:
- lib/puppet_forge_server/http/http_client.rb
Instance Method Summary collapse
Instance Method Details
#download(url) ⇒ Object
44 45 46 |
# File 'lib/puppet_forge_server/http/http_client.rb', line 44 def download(url) open_uri(url) end |
#get(url) ⇒ Object
40 41 42 |
# File 'lib/puppet_forge_server/http/http_client.rb', line 40 def get(url) open_uri(url).read end |
#post_file(url, file_hash, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet_forge_server/http/http_client.rb', line 27 def post_file(url, file_hash, = {}) = { :http => {}, :headers => {}}.merge() uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) [:http].each {|k,v| http.call(k, v) } req = Net::HTTP::Post::Multipart.new uri.path, "file" => UploadIO.new(File.open(file_hash[:tempfile]), file_hash[:type], file_hash[:filename]) [:headers].each {|k,v| req[k] = v } http.request(req) end |