lib/packetgen/header/http/headers.rb in packetgen-2.8.7 vs lib/packetgen/header/http/headers.rb in packetgen-3.0.0

- old
+ new

@@ -27,10 +27,11 @@ def read(s_or_h) case s_or_h when String @data = s_or_h.split("\n").map do |h| next unless h.include?(':') + k, v = h.split(':', 2) [k, v.strip] end.reject(&:nil?).to_h when Hash @data = s_or_h @@ -40,10 +41,11 @@ # Get binary string. # @return [String] def to_s return "\r\n" if @data.nil? || @data.empty? + d = [] @data.map do |k, v| d << k + ': ' + v end d.join("\r\n") << "\r\n\r\n" @@ -64,9 +66,10 @@ # Check if any headers were given. # @return [Boolean] def given? return true unless @data.nil? || @data.empty? + false end end end end