Class: Azure::Core::Http::HttpRequest
- Inherits:
-
Object
- Object
- Azure::Core::Http::HttpRequest
- Defined in:
- lib/mswin-build/azure-patch.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mswin-build/azure-patch.rb', line 44 def call request = http_request_class.new(uri.request_uri, headers) if IO === body request.body_stream = body elsif body request.body = body end http = nil if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY'] if ENV['HTTP_PROXY'] proxy_uri = URI::parse(ENV['HTTP_PROXY']) else proxy_uri = URI::parse(ENV['HTTPS_PROXY']) end http = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(uri.host, uri.port) else http = Net::HTTP.new(uri.host, uri.port) end if uri.scheme.downcase == 'https' # require 'net/https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end response = HttpResponse.new(http.request(request)) response.uri = uri raise response.error unless response.success? response end |
#default_headers(current_time) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mswin-build/azure-patch.rb', line 22 def default_headers(current_time) headers["User-Agent"] = "Azure-SDK-For-Ruby/" + Azure::Version.to_s headers["x-ms-date"] = current_time headers["x-ms-version"] = "2012-02-12" headers["DataServiceVersion"] = "1.0;NetFx" headers["MaxDataServiceVersion"] = "2.0;NetFx" if body headers["Content-Type"] = "application/atom+xml; charset=utf-8" if IO === body headers["Content-Length"] = body.size.to_s headers["Content-MD5"] = Digest::MD5.file(body.path).base64digest else headers["Content-Length"] = body.bytesize.to_s headers["Content-MD5"] = Base64.strict_encode64(Digest::MD5.digest(body)) end else headers["Content-Length"] = "0" headers["Content-Type"] = "" end end |