Skip to content

feat: add Nack::Response - #78

Merged
himura467 merged 1 commit into
mainfrom
feat-response
Nov 2, 2026
Merged

himura467 merged 1 commit into
mainfrom
feat-response

Conversation

@himura467

Copy link
Copy Markdown
Contributor

Closes #17

  • Adds Nack::Response, which builds a response and finishes it into the triplet SPEC.md section 4 requires.
  • new(status = 200, headers = [], body = nil) keeps headers as a Nack::Headers and copies body into a binary String that write appends to.
  • content_type, content_length and location read and set their fields, and assigning nil deletes them. content_length= raises Nack::SpecError unless given a non-negative Integer.
  • redirect(location, status = 302) sets the location and status.
  • set_cookie raises ArgumentError on a name, value or attribute outside the rfc6265bis grammar, accepting an expires in 1900..9999 (RFC 5322 section 3.3), and replaces any set-cookie field of the same name (rfc6265bis section 4.1.1). delete_cookie sets an empty cookie that expired at the epoch.
  • finish returns [Integer, Array of fields, String], drops the body of a 204, 205 and 304, and wraps the body in an object responding to #each and #trailers (SPEC.md section 4.4) once a trailer is added.

@himura467
himura467 merged commit 30da1b7 into main Nov 2, 2026
4 checks passed
@himura467
himura467 deleted the feat-response branch November 2, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Nack::Response

1 participant