Sha256: ddf929e9a3f2a9df057da464cc6db10f62ba66957c7484a03e48d5c789c4fa70

Contents?: true

Size: 524 Bytes

Versions: 6

Compression:

Stored size: 524 Bytes

Contents

require 'base64'

module HTTP
  module AuthorizationHeader
    # Basic authorization header builder
    # @see http://tools.ietf.org/html/rfc2617
    class BasicAuth
      # @param [#fetch] opts
      # @option opts [#to_s] :user
      # @option opts [#to_s] :pass
      def initialize(opts)
        @user = opts.fetch :user
        @pass = opts.fetch :pass
      end

      # :nodoc:
      def to_s
        'Basic ' << Base64.strict_encode64("#{@user}:#{@pass}")
      end
    end

    register :basic, BasicAuth
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
http-0.6.4 lib/http/authorization_header/basic_auth.rb
http-0.6.3 lib/http/authorization_header/basic_auth.rb
http-0.6.2 lib/http/authorization_header/basic_auth.rb
http-0.6.1 lib/http/authorization_header/basic_auth.rb
http-0.6.0 lib/http/authorization_header/basic_auth.rb
http-0.6.0.pre lib/http/authorization_header/basic_auth.rb