lib/protocol/http/headers.rb in protocol-http-0.21.0 vs lib/protocol/http/headers.rb in protocol-http-0.22.0
- old
+ new
@@ -35,11 +35,11 @@
# Headers are an array of key-value pairs. Some header keys represent multiple values.
class Headers
Split = Header::Split
Multiple = Header::Multiple
- TRAILERS = 'trailers'
+ TRAILER = 'trailer'
# Construct an instance from a headers Array or Hash. No-op if already an instance of `Headers`. If the underlying array is frozen, it will be duped.
# @return [Headers] an instance of headers.
def self.[] headers
if headers.nil?
@@ -65,11 +65,11 @@
def initialize(fields = [], indexed = nil)
@fields = fields
@indexed = indexed
- # Marks where trailers start in the @fields array.
+ # Marks where trailer start in the @fields array.
@tail = nil
end
def initialize_dup(other)
super
@@ -82,14 +82,14 @@
@fields.clear
@indexed = nil
@tail = nil
end
- # Flatten trailers into the headers.
+ # Flatten trailer into the headers.
def flatten!
if @tail
- self.delete(TRAILERS)
+ self.delete(TRAILER)
@tail = nil
end
return self
end
@@ -99,30 +99,30 @@
end
# An array of `[key, value]` pairs.
attr :fields
- # @return the trailers if there are any.
- def trailers?
+ # @return the trailer if there are any.
+ def trailer?
@tail != nil
end
- # Record the current headers, and prepare to receive trailers.
- def trailers!(&block)
- return nil unless self.include?(TRAILERS)
+ # Record the current headers, and prepare to receive trailer.
+ def trailer!(&block)
+ return nil unless self.include?(TRAILER)
@tail ||= @fields.size
- return to_enum(:trailers!) unless block_given?
+ return to_enum(:trailer!) unless block_given?
if @tail
@fields.drop(@tail).each(&block)
end
end
- # Enumerate all trailers, if there are any.
- def trailers(&block)
- return to_enum(:trailers) unless block_given?
+ # Enumerate all headers in the trailer, if there are any.
+ def trailer(&block)
+ return to_enum(:trailer) unless block_given?
if @tail
@fields.drop(@tail).each(&block)
end
end