vendor/bundle/ruby/2.1.0/gems/httpauth-0.2.1/lib/httpauth/digest.rb
def encode_directives(h, variant)
          encode = {:domain => :list_to_space_quoted_string, :algorithm => false, :stale => :bool_to_str, :nc => :int_to_hex}
          if [:credentials, :auth].include? variant
            encode.merge! :qop => false
          elsif variant == :challenge
            encode.merge! :qop => :list_to_comma_quoted_string
          else
            fail(ArgumentError, "#{variant} is not a valid value for `variant' use :auth, :credentials or :challenge")
          end
          (variant == :auth ? '' : 'Digest ') + h.collect do |directive, value|
            '' << directive.to_s << '=' << if encode[directive]
              begin
                Conversions.send encode[directive], value
              rescue NoMethodError, ArgumentError
                raise(ArgumentError, "Can't encode #{directive}(#{value.inspect}) with #{encode[directive]}")
              end
            elsif encode[directive].nil?
              begin
                Conversions.quote_string value
              rescue NoMethodError, ArgumentError
                raise(ArgumentError, "Can't encode #{directive}(#{value.inspect}) with quote_string")
              end
            else
              value
            end
          end.join(', ')
        end
# Encodes a hash with digest directives to send in a header.
#
# * <tt>h</tt>: The directives specified in a hash
# * <tt>variant</tt>: Specifies whether the directives are for an Authorize header (:credentials),
#   for a WWW-Authenticate header (:challenge) or for a Authentication-Info header (:auth_info).
Encodes a hash with digest directives to send in a header.
Encodes a hash with digest directives to send in a header .
def encode_directives(h, variant)
          encode = {:domain => :list_to_space_quoted_string, :algorithm => false, :stale => :bool_to_str, :nc => :int_to_hex}
          if [:credentials, :auth].include? variant
            encode.merge! :qop => false
          elsif variant == :challenge
            encode.merge! :qop => :list_to_comma_quoted_string
          else
            fail(ArgumentError, "#{variant} is not a valid value for `variant' use :auth, :credentials or :challenge")
          end
          (variant == :auth ? '' : 'Digest ') + h.collect do |directive, value|
            '' << directive.to_s << '=' << if encode[directive]
              begin
                Conversions.send encode[directive], value
              rescue NoMethodError, ArgumentError
                raise(ArgumentError, "Can't encode #{directive}(#{value.inspect}) with #{encode[directive]}")
              end
            elsif encode[directive].nil?
              begin
                Conversions.quote_string value
              rescue NoMethodError, ArgumentError
                raise(ArgumentError, "Can't encode #{directive}(#{value.inspect}) with quote_string")
              end
            else
              value
            end
          end.join(', ')
        end
def encode_directives ( h , variant ) encode = { :domain => :list_to_space_quoted_string , :algorithm => false , :stale => :bool_to_str , :nc => :int_to_hex } if [ :credentials , :auth ] . include? variant encode . merge! :qop => false elsif variant == :challenge encode . merge! :qop => :list_to_comma_quoted_string else fail ( ArgumentError , "#{variant} is not a valid value for `variant' use :auth, :credentials or :challenge" ) end ( variant == :auth ? '' : 'Digest ' ) + h . collect do | directive , value | '' << directive . to_s << '=' << if encode [ directive ] begin Conversions . send encode [ directive ] , value rescue NoMethodError , ArgumentError raise ( ArgumentError , "Can't encode #{directive}(#{value.inspect}) with #{encode[directive]}" ) end elsif encode [ directive ] . nil? begin Conversions . quote_string value rescue NoMethodError , ArgumentError raise ( ArgumentError , "Can't encode #{directive}(#{value.inspect}) with quote_string" ) end else value end end . join ( ', ' ) end
Encodes a hash with digest directives to send in a header.
Encodes a hash with digest directives to send in a header .
h
variant