Creates a new HTTP wrapper to handle the network portions of the API requests
 @param [Hash] args Same as [SmugMug::HTTP]
345137
def request(api, args)
      uri = api == :uploading ? UPLOAD_URI : API_URI
      args[:method] = "smugmug.#{api}" unless api == :uploading

      http = ::Net::HTTP.new(uri.host, uri.port, @http_proxy_host, @http_proxy_port, @http_proxy_user, @http_proxy_pass)
      http.set_debug_output(@config[:debug_output]) if @config[:debug_output]

      # Configure HTTPS if needed
      if uri.scheme == "https"
        http.use_ssl = true

        if @config[:http] and @config[:http][:verify_mode]
          http.verify_mode = @config[:http][:verify_mode]
          http.ca_file = @config[:http][:ca_file]
          http.ca_path = @config[:http][:ca_path]
        else
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
      end

      # Upload request, which requires special handling
      if api == :uploading
        postdata = args.delete(:content)
        headers = @headers.merge("Content-Length" => postdata.length.to_s, "Content-MD5" => Digest::MD5.hexdigest(postdata), "X-Smug-Version" => "1.3.0", "X-Smug-ResponseType" => "JSON")

        UPLOAD_HEADERS.each do |key|
          next unless args[key] and args[key] != ""
          headers["X-Smug-#{key}"] = args[key].to_s
        end

        oauth = self.sign_request("POST", uri, nil)
        headers["Authorization"] = "OAuth oauth_consumer_key=\"#{oauth["oauth_consumer_key"]}\", oauth_nonce=\"#{oauth["oauth_nonce"]}\", oauth_signature_method=\"#{oauth["oauth_signature_method"]}\", oauth_signature=\"#{oauth["oauth_signature"]}\", oauth_timestamp=\"#{oauth["oauth_timestamp"]}\", oauth_version=\"#{oauth["oauth_version"]}\", oauth_token=\"#{oauth["oauth_token"]}\""

      # Normal API method
      else
        postdata = self.sign_request("POST", uri, args)
        headers = @headers
      end

      response = http.request_post(uri.request_uri, postdata, headers)
      if response.code == "204"
        return nil
      elsif response.code != "200"
        raise SmugMug::HTTPError.new("HTTP #{response.code}, #{response.message}", response.code, response.message)
      end

      # Check for GZIP encoding
      if response.header["content-encoding"] == "gzip"
        begin
          body = Zlib::GzipReader.new(StringIO.new(response.body)).read
        rescue Zlib::GzipFile::Error
          raise
        end
      else
        body = response.body
      end

      return nil if body == ""

      data = JSON.parse(body)

      if data["stat"] == "fail"
        # Special casing for SmugMug being in Read only mode
        if data["code"] == 99
          raise SmugMug::ReadonlyModeError.new("SmugMug is currently in read only mode, try again later")
        end

        klass = OAUTH_ERRORS[data["code"]] ? SmugMug::OAuthError : SmugMug::RequestError
        raise klass.new("Error ##{data["code"]}, #{data["message"]}", data["code"], data["message"])
      end

      data.delete("stat")
      data.delete("method")

      # smugmug.albums.changeSettings at the least doesn't return any data
      return nil if data.length == 0

      # It seems all smugmug APIs only return one hash of data, so this should be fine and not cause issues
      data.each do |_, value|
        return value
      end
    end
585553
def post(url, req_hash={})
      res = nil
      res = perform_op(:post, req_hash) do
        res = @wrapper.post(url, req_hash)
      end
      return res
    end
592831
def http(container = None):
    ""
    def decorator(func):
        @functools.wraps(func)
        def handler(self, event):
            return _handler(self if container is None else container, event, lambda env: func(self, env))
        return handler
    return decorator
429754
function http_request_args( $args, $url ) {
		// If it is an https request and we are performing a package download, disable ssl verification.
		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
			$args['sslverify'] = false;
		}

		return $args;
	}
309591
def create_http_request(http_method, path, *arguments)
      http_method = http_method.to_sym

      if [:post, :put, :patch].include?(http_method)
        data = arguments.shift
      end

      # if the base site contains a path, add it now
      # only add if the site host matches the current http object's host
      # (in case we've specified a full url for token requests)
      uri  = URI.parse(site)
      path = uri.path + path if uri.path && uri.path != '/' && uri.host == http.address

      headers = arguments.first.is_a?(Hash) ? arguments.shift : {}

      case http_method
      when :post
        request = Net::HTTP::Post.new(path,headers)
        request["Content-Length"] = '0' # Default to 0
      when :put
        request = Net::HTTP::Put.new(path,headers)
        request["Content-Length"] = '0' # Default to 0
      when :patch
        request = Net::HTTP::Patch.new(path,headers)
        request["Content-Length"] = '0' # Default to 0
      when :get
        request = Net::HTTP::Get.new(path,headers)
      when :delete
        request =  Net::HTTP::Delete.new(path,headers)
      when :head
        request = Net::HTTP::Head.new(path,headers)
      else
        raise ArgumentError, "Don't know how to handle http_method: :#{http_method.to_s}"
      end

      if data.is_a?(Hash)
        request.body = OAuth::Helper.normalize(data)
        request.content_type = 'application/x-www-form-urlencoded'
      elsif data
        if data.respond_to?(:read)
          request.body_stream = data
          if data.respond_to?(:length)
            request["Content-Length"] = data.length.to_s
          elsif data.respond_to?(:stat) && data.stat.respond_to?(:size)
            request["Content-Length"] = data.stat.size.to_s
          else
            raise ArgumentError, "Don't know how to send a body_stream that doesn't respond to .length or .stat.size"
          end
        else
          request.body = data.to_s
          request["Content-Length"] = request.body.length.to_s
        end
      end

      request
    end
672937
def default_url_options(*args)
      defaults = {}
      request  = Thread.current["actiondispatch.request"]

      if request
        host     = request.host
        port     = request.port
        protocol = request.protocol
        standard_port = request.standard_port

        defaults[:protocol] = protocol
        defaults[:host]     = host
        defaults[:port]     = port if port != standard_port
      end

      super.merge(defaults)
    end
1367807
def api_url
      @api_url ||= Addressable::URI.new(
        :scheme => scheme, :host => host, :port => port,
        :path => path_with_base("/_api", resource_path)
      ).normalize.to_s
    end
523112
def url
      sch = @options[:ssl] ? "https" : "http"
      hosts = Array(@options[:host])
      @url ||= if hosts.first.include?(":")
                 URI("#{sch}://[#{hosts.first}]:#{port}").to_s
               else
                 URI("#{sch}://#{hosts.first}:#{port}").to_s
               end
    end
987353
def request(uri)
      case
      when method == :get
        request = Net::HTTP::Get.new(uri)
      when method == :put
        request = Net::HTTP::Put.new(uri)
        request['Content-Type'] = 'application/json'
        if ref
          header = ref == '"*"' ? 'If-None-Match' : 'If-Match'
          request[header] = ref
        end
        request.body = data
      when method == :delete
        request = Net::HTTP::Delete.new(uri)
      end

      request['Orchestrate-Client'] = "ruby/orchestrate-api/#{Orchestrate::VERSION}"
      request.basic_auth @user, nil
      request
    end
897056
def wrap(http_method, url, params)
      params = params.merge(:appid => @appid)
      params[:sig] = Gateway.signature( "#{@appkey}&", Gateway.make_source(http_method.to_s.upcase, url, params) )
      params
    end
1225824
def connection_repo
      @options[:path] = API_REST + @options[:path]

      @options[:headers] = HEADERS.merge(AUTH_PREFIX => @final_hash[:creds]).merge(@options[:headers])

      text.msg('HTTP Request Data:')
      text.msg("> HTTP #{@options[:scheme]}://#{@options[:host]}")
      @options.each do |key, value|
        text.msg("> #{key}: #{value}")
      end
      text.msg('End HTTP Request Data.')
      if @options[:scheme] == 'https'
        @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}", @options)
      else
        Excon.defaults[:ssl_verify_peer] = false
        @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:6001", @options)
      end
      @connection
      end
308075
def get_request(url,args)
      uri = URI.parse url

      # ck is the current unix timestamp
      args[:ck] = Time.now.to_i unless args[:ck]

      req = Net::HTTP::Get.new("#{uri.path}?#{argument_string(args)}")
      request(uri,req)
    end
320179
def connect
      http = Net::HTTP.new(host, port)
      http.use_ssl = ssl

      begin
        yield http
      rescue *HTTP_ERRORS => exception
        raise ConnectionError, "#{exception.class.name}: #{exception.message}"
      end
    end
174704
def connection
      @options[:path] =API_VERSION1+ @options[:path]
      @options[:headers] = HEADERS.merge(@options[:headers])

      Megam::Log.debug("HTTP Request Data:")
      Megam::Log.debug("> HTTP #{@options[:scheme]}://#{@options[:host]}")
      @options.each do |key, value|
        Megam::Log.debug("> #{key}: #{value}")
      end
      Megam::Log.debug("End HTTP Request Data.")
      @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}",@options)
    end
695687
function HTTPServer(options) {
  if (!(this instanceof HTTPServer))
    return new HTTPServer(options);

  options = new HTTPOptions(options);

  HTTPBase.call(this, options);

  this.options = options;
  this.network = this.options.network;
  this.logger = this.options.logger.context('http');
  this.node = this.options.node;

  this.chain = this.node.chain;
  this.mempool = this.node.mempool;
  this.pool = this.node.pool;
  this.fees = this.node.fees;
  this.miner = this.node.miner;
  this.rpc = this.node.rpc;

  this.init();
}
590202
def perform(arguments = {})
      case type.to_sym
      when :post, :get
        api.public_send(type, path, @arguments.merge(arguments))
      else
        raise ArgumentError, "Unregistered request type #{request_type}"
      end
    end
543198
def call(req, args={}, &block)
      oauth_args = args.delete(:oauth) || {}
      http_response = @oauth_consumer.post_form(REST_PATH, @access_secret, {:oauth_token => @access_token}.merge(oauth_args), build_args(args, req))
      process_response(req, http_response.body)
    end