Sha256: 96a50a13aeeb8dced17ec29a98c3cb070eedc047b8e0421718018b651e6f6184

Contents?: true

Size: 609 Bytes

Versions: 7

Compression:

Stored size: 609 Bytes

Contents

module Spectre::Http
  class SpectreHttpRequest
    def basic_auth username, password
      @__req['basic_auth'] = {} if not @__req.key? 'basic_auth'

      @__req['basic_auth']['username'] = username
      @__req['basic_auth']['password'] = password

      @__req['auth'] = 'basic_auth'
    end
  end

  module BasicAuth
    def self.on_req http, net_req, req
      return unless req.key? 'basic_auth' and req['auth'] == 'basic_auth'
      basic_auth_cfg = req['basic_auth']
      net_req.basic_auth(basic_auth_cfg['username'], basic_auth_cfg['password'])
    end

    Spectre::Http.register(self)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spectre-core-1.11.0 lib/spectre/http/basic_auth.rb
spectre-core-1.10.0 lib/spectre/http/basic_auth.rb
spectre-core-1.9.0 lib/spectre/http/basic_auth.rb
spectre-core-1.8.4 lib/spectre/http/basic_auth.rb
spectre-core-1.8.3 lib/spectre/http/basic_auth.rb
spectre-core-1.8.2 lib/spectre/http/basic_auth.rb
spectre-core-1.8.1 lib/spectre/http/basic_auth.rb