sammhicks / picoserve

An async no_std HTTP server suitable for bare-metal environments, heavily inspired by axum
MIT License
209 stars 27 forks source link

Refactor header parsing #40

Closed simpkins closed 6 months ago

simpkins commented 6 months ago

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.

simpkins commented 6 months ago

Abandoning this for now since I have come up with a better proposed API in my latest comment on #39.