Skip to content

Commit

Permalink
Add documentation for HTTP::Headers#add (#13762)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Thorne <[email protected]>
  • Loading branch information
jkthorne and jkthorne authored Aug 28, 2023
1 parent e351dde commit d8be15a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/http/headers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ struct HTTP::Headers
false
end

# Adds a header with *key* and *value* to the header set. If a header with
# *key* already exists in the set, *value* is appended to the existing header.
#
# ```
# require "http/headers"
#
# headers = HTTP::Headers.new
# headers.add("Connection", "keep-alive")
# headers["Connection"] # => "keep-alive"
# headers.add("Connection", "Upgrade")
# headers["Connection"] # => "keep-alive,Upgrade"
# ```
def add(key, value : String) : self
check_invalid_header_content value
unsafe_add(key, value)
Expand Down

0 comments on commit d8be15a

Please sign in to comment.