Sha256: 80cf4fea19630e9e24baa10c46cd6fd6ed25a6bdeea3dcb4dd667261c524cc04
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
module MicrosoftKiotaAbstractions class RequestHeaders def initialize() @headers = Hash.new end def add(key, value) if key.nil? || key.empty? || value.nil? || value.empty? then raise ArgumentError, 'key and value cannot be nil or empty' end existing_value = @headers[key] if existing_value.nil? then if value.kind_of?(Array) then @headers[key] = value else @headers[key] = Array[value.to_s] end else if value.kind_of?(Array) then @headers[key] = existing_value | value else existing_value << value.to_s end end end def try_add(key, value) if key.nil? || key.empty? || value.nil? || value.empty? then raise ArgumentError, 'key and value cannot be nil or empty' end existing_value = @headers[key] if existing_value.nil? || existing_value.empty? then @headers[key] = Array[value.to_s] return true else return false end end def get(key) if key.nil? || key.empty? then raise ArgumentError, 'key cannot be nil or empty' end return @headers[key] end def remove(key) if key.nil? || key.empty? then raise ArgumentError, 'key cannot be nil or empty' end @headers.delete(key) end def clear() @headers.clear() end def get_all() return @headers end end end
Version data entries
3 entries across 3 versions & 1 rubygems