lib/packetgen/header/http/headers.rb in packetgen-3.3.1 vs lib/packetgen/header/http/headers.rb in packetgen-3.3.2

- old
+ new

@@ -1,10 +1,11 @@ # frozen_string_literal: true # This file is part of PacketGen -# See https://github.com/sdaubert/packetgen for more informations +# See https://github.com/lemontree55/packetgen for more informations # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> +# Copyright (C) 2024 LemonTree55 <lenontree@proton.me> # This program is published under MIT license. module PacketGen module Header # @since 2.2.0 @@ -27,15 +28,15 @@ # @param [String, Hash] s_or_h # @return [self] def read(s_or_h) case s_or_h when String - @data = s_or_h.split("\n").map do |h| + @data = s_or_h.split("\n").filter_map do |h| next unless h.include?(':') k, v = h.split(':', 2) [k, v.strip] - end.compact.to_h + end.to_h when Hash @data = s_or_h end self end