lib/htty/request.rb
def header_set(name, value)
    return dup_without_response.header_set(name, value) if response

    name = name && name.to_s
    value = value && value.to_s

    # to avoid recursion when rebuild_uri
    return self if @headers[name] == value

    if value.nil?
      @headers.delete name
      if name.downcase == AUTHORIZATION_HEADER_NAME.downcase
        return rebuild_uri userinfo: nil
      end
      return self
    end

    @headers[name] = value
    if name.downcase == AUTHORIZATION_HEADER_NAME.downcase
      HTTY::Headers.credentials_from(value) do |username, password|
        return rebuild_uri userinfo: [
          HTTY::URI.escape_component(username),
          HTTY::URI.escape_component(password)
        ].compact.join(':')
      end
    end
    self
  end
# Appends to #headers or changes the element of #headers using the specified
# _name_ and _value_.
Appends to #headers or changes the element of #headers using the specified
_name_ and _value_.
Appends to #headers or changes the element of #headers using the specified _name_ and _value_ .
def header_set(name, value)
    return dup_without_response.header_set(name, value) if response
    name = name && name.to_s
    value = value && value.to_s
    return self if @headers[name] == value
    if value.nil?
      @headers.delete name
      if name.downcase == AUTHORIZATION_HEADER_NAME.downcase
        return rebuild_uri userinfo: nil
      end
      return self
    end
    @headers[name] = value
    if name.downcase == AUTHORIZATION_HEADER_NAME.downcase
      HTTY::Headers.credentials_from(value) do |username, password|
        return rebuild_uri userinfo: [
          HTTY::URI.escape_component(username),
          HTTY::URI.escape_component(password)
        ].compact.join(':')
      end
    end
    self
  end
def header_set ( name , value ) return dup_without_response . header_set ( name , value ) if response name = name && name . to_s value = value && value . to_s return self if @headers [ name ] == value if value . nil? @headers . delete name if name . downcase == AUTHORIZATION_HEADER_NAME . downcase return rebuild_uri userinfo : nil end return self end @headers [ name ] = value if name . downcase == AUTHORIZATION_HEADER_NAME . downcase HTTY :: Headers . credentials_from ( value ) do | username , password | return rebuild_uri userinfo : [ HTTY :: URI . escape_component ( username ) , HTTY :: URI . escape_component ( password ) ] . compact . join ( ':' ) end end self end
Appends to #headers or changes the element of #headers using the specified
_name_ and _value_.
Appends to #headers or changes the element of #headers using the specified _name_ and _value_ .
# to avoid recursion when rebuild_uri
name
value