Module: CF::UAA::Http

Includes:
ProxyOptions
Included in:
Info, Scim, TokenIssuer
Defined in:
lib/uaa/http.rb

Overview

Utility accessors and methods for objects that want to access JSON web APIs.

Constant Summary collapse

JSON_UTF8 =
"application/json;charset=utf-8"
FORM_UTF8 =
"application/x-www-form-urlencoded;charset=utf-8"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProxyOptions

#proxy_options_for

Class Method Details

.basic_auth(name, password) ⇒ String

Constructs an http basic authentication header.

Returns:

  • (String)


79
80
81
82
83
# File 'lib/uaa/http.rb', line 79

def self.basic_auth(name, password)
  str = "#{name}:#{password}"
  "Basic " + (Base64.respond_to?(:strict_encode64)?
      Base64.strict_encode64(str): [str].pack("m").gsub(/\n/, ''))
end

Instance Method Details

#loggerLogger

The current logger or Util.default_logger if none has been set.

Returns:

  • (Logger)


64
# File 'lib/uaa/http.rb', line 64

def logger ; @logger || Util.default_logger end

#logger=(logr) ⇒ Logger

Sets the current logger instance to recieve error messages.

Parameters:

  • logr (Logger)

Returns:

  • (Logger)


60
# File 'lib/uaa/http.rb', line 60

def logger=(logr); @logger = logr end

#set_request_handler(&blk) ⇒ nil

Sets a handler for outgoing http requests. If no handler is set, an internal cache of net/http connections is used. Arguments to the handler are url, method, body, headers.

Parameters:

  • blk (Proc)

    handler block

Returns:

  • (nil)


75
# File 'lib/uaa/http.rb', line 75

def set_request_handler(&blk) @req_handler = blk; nil end

#trace?Boolean

Indicates if the current logger is set to :trace level.

Returns:

  • (Boolean)


68
# File 'lib/uaa/http.rb', line 68

def trace? ; (lgr = logger).respond_to?(:trace?) && lgr.trace? end