This changes the header parsing logic, to implement the changes
discussed in #39. In particular, this no longer attempts to do
percent-decoding, and also does more validation of the header contents
to adhere more closely to RFCs 9110 and 9112.
I did end up replacing the Subslice code with a new ReadHelper class.
This API seems a bit simpler and safer to me since it largely operates
on slices rather than offsets and ranges. The one case where the
ReadHelper API still feels a bit awkward here is dealing with the any
leftover portion of data after a request that may be from the new
request. I think this could probably be cleaned up in the future if
desired. It seems like we would need to refactor this somewhat in the
future anyway if we ever want to support chunked transfer encoding of
POST bodies.
The other reason I added the ReadHelper API is because I think it will
make it easier to use ReadHelper in the future for other use cases,
like reading headers in a multipart/form-data POST body or the
trailers of a chunked POST body.
This changes the header parsing logic, to implement the changes discussed in #39. In particular, this no longer attempts to do percent-decoding, and also does more validation of the header contents to adhere more closely to RFCs 9110 and 9112.
I did end up replacing the Subslice code with a new ReadHelper class. This API seems a bit simpler and safer to me since it largely operates on slices rather than offsets and ranges. The one case where the ReadHelper API still feels a bit awkward here is dealing with the any leftover portion of data after a request that may be from the new request. I think this could probably be cleaned up in the future if desired. It seems like we would need to refactor this somewhat in the future anyway if we ever want to support chunked transfer encoding of POST bodies.
The other reason I added the
ReadHelper
API is because I think it will make it easier to useReadHelper
in the future for other use cases, like reading headers in amultipart/form-data
POST body or the trailers of a chunkedPOST
body.