Makes a HTTP request after signing the headers
 @return [Hash] the body from the HTTP request
496841
def body
      raise RequestError, 'The request requires a HTTP method.' unless @http_method
      raise RequestError, 'The payload needs to be a hash.' unless @payload.to_s.empty? || @payload.is_a?(Hash)

      res = Net::HTTP.start(uri.hostname, Yoti.configuration.api_port, use_ssl: https_uri?) do |http|
        signed_request = SignedRequest.new(unsigned_request, path, @payload).sign
        http.request(signed_request)
      end

      raise RequestError, "Unsuccessful Yoti API call: #{res.message}" unless res.code == '200'

      res.body
    end
222025
def request(method, path, params, options)
      uri = options[:host] || @host
      uri = URI(uri) unless uri.respond_to?(:host)
      uri += path
      request_headers = {}
      if self.credentials?
        # When posting a file, don't sign any params
        # signature_params = if [:post, :put].include?(method.to_sym) && params.values.any?{|value| value.is_a?(File) || (value.is_a?(Hash) && (value[:io].is_a?(IO) || value[:io].is_a?(StringIO)))}
        #   {}
        # else
        #   params
        # end
        # authorization = SimpleOAuth::Header.new(method, uri, signature_params, credentials)
        # request_headers[:authorization] = authorization.to_s
        connection.basic_auth(credentials[:user], credentials[:password])
      end
      connection.url_prefix = options[:host] || @host
      connection.run_request(method.to_sym, path, nil, request_headers) do |request|
        unless params.empty?
          case request.method
          when :post, :put
            request.body = params
          else
            request.params.update(params)
          end
        end
        yield request if block_given?
      end.env
    rescue Faraday::Error::ClientError
      raise VulnDBHQ::Error::ClientError
    end
890049
def body
      if content_type_is_form && request.body.is_a?(Hash)
        URI.encode_www_form convert_hash_body_to_array_of_arrays
      else
        Pact::Reification.from_term(request.body)
      end
    end
702303
def create_http
      http = Net::HTTP.new(
        API_URI.host, 
        API_URI.port
      )
      http.use_ssl = true
      apply_ca_cert_path(http)
      apply_pem(http)
      http
    end
733844
def normalize_request_headers(env)
      req_headers = env.reject {|k,v| !k.start_with? "HTTP_" }
      normalized = req_headers.map do |k, v|
        new_key = k.sub("HTTP_",'').split('_').map(&:capitalize).join('-')
        [new_key, v] unless UNWANTED_REQUEST_HEADERS.include? new_key
      end
      Hash[normalized]
    end
418281
def get(url)

      data = nil
      resp = HTTParty.get(url)

      if resp.code == 200
        return resp.body
      end
    end
331095
def get(path, options = {}, headers = {}, raw = false)
      request(:get, path, options, headers, raw)
    end
682216
def sign_in
      @client_security_token = @x_security_token = nil

      body = { identifier: username, password: password_encryptor.encrypt(password), encryptedPassword: true }

      sign_in_result = request method: :post, url: 'session', body: body, api_version: API_V2

      headers = sign_in_result.fetch(:response).headers
      @client_security_token = headers.fetch 'CST'
      @x_security_token = headers.fetch 'X-SECURITY-TOKEN'

      sign_in_result.fetch :body
    end
242452
def request_body_from(req, body)
      req.body.nil? || req.body.size == 0 ? body : req.body
    end
1072486
def request(method, *options)
      response_handler = if options.last.is_a?(Hash) && options.last[:handler]
                           options.last.delete(:handler)
                         else
                           handler
                         end

      self.class.base_uri Jiralicious.uri
      before_request if respond_to?(:before_request)
      response = self.class.send(method, *options)
      after_request(response) if respond_to?(:after_request)

      response_handler.call(response)
    end
1297468
def sign(post_body)
      custom_escape(Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, @secret_key, post_body)))
    end
482270
def raw
      headers = http_headers.map { |k, v| "#{k}: #{v}\r\n" }.join
      format "%s %s %s\r\n%s\r\n%s", request_method.upcase, fullpath, env["SERVER_PROTOCOL"], headers, body_string
    end
1245168
def headers
      list = @response.header_str.split(/[\r\n]+/).map(&:strip)
      Hash[list.flat_map{ |s| s.scan(/^(\S+): (.+)/) }.map { |pair|
        [pair.first.to_s.camelcase, pair.second]
      }]
    end
1330536
def getBody(cls, url, method='GET', headers={}, data=None, socket=None, timeout=120):
        
        if not 'User-Agent' in headers:
            headers['User-Agent'] = ['Tensor HTTP checker']

        return cls().request(url, method, headers, data, socket, timeout)
1140325
def to_hash
      {
        'status'       => status.to_hash,
        'headers'      => headers,
        'body'         => serializable_body,
        'http_version' => http_version
      }.tap do |hash|
        hash['adapter_metadata'] = adapter_metadata unless adapter_metadata.empty?
      end
    end
362482
def generate_canonical_request(method, parsed_url, headers, signed_headers, content_sha256):
    
    lines = [method, parsed_url.path, parsed_url.query]

    # Headers added to canonical request.
    header_lines = []
    for header in signed_headers:
        value = headers[header.title()]
        value = str(value).strip()
        header_lines.append(header + ':' + str(value))

    lines = lines + header_lines
    lines.append('')

    lines.append(';'.join(signed_headers))
    lines.append(content_sha256)
    return '\n'.join(lines)
126728
def make_request_headers(opts)
      headers = opts.headers

      # Tell the server to keep the conn open
      headers[Headers::CONNECTION] = default_options.persistent? ? Connection::KEEP_ALIVE : Connection::CLOSE

      cookies = opts.cookies.values

      unless cookies.empty?
        cookies = opts.headers.get(Headers::COOKIE).concat(cookies).join("; ")
        headers[Headers::COOKIE] = cookies
      end

      headers
    end