swift-server / swift-server/swift-http-server

Should NIOHTTPServer.Reader.read pass iterator back to ReaderState on body error

Open
#131 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
44
Forks
13
Avg merge
4d 3h
Merged PRs (30d)
8

Description

Currently when the body closure in NIOHTTPServer.Reader.read(body:) throws an error the iterator is not passed back to the ReaderState. This means after an error has been thrown the iterator is no longer available and the connection cannot be recovered. I don't think an error in body should mean a connection is dropped.

Of course if we allow this to happen then the server will have to parse the remain body/end parts before it starts handling a new request

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at NIOHTTPServer.Reader.read(body:) and trace how ReaderState receives or loses the iterator when the body closure throws. Check the surrounding request-body and end-part handling, then verify that the remaining body is consumed before a new request is processed. Done means a body error does not drop the connection and the iterator is available for recovery.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.