sammhicks / picoserve

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

Add double-quote to acceptable bytes in header to fix error caused by If-None-Match #35

Closed philcrump closed 6 months ago

philcrump commented 6 months ago

Issue

Issue experienced using picoserve 0.10.1 on STM32 platform with embassy.

Any browser HTTP request containing the header "If-None-Match" returned "Invalid Byte in Header". This can be reproduced in Firefox by loading a webpage, and then clicking the refresh button, with caching enabled if Developer Tools is open.

As per MDN the Etag value in the If-None-Match header is contained in double-quotes, inside the Header value.

Resolution

Adding the double-quote character to the acceptable characters in this check resolves this issue on my platform and browser requests are returned successfully. Please do let me know if there's a better way to fix this.

Thanks for the library!

sammhicks commented 6 months ago

Thanks for the fix! It's technically too permissive, but given the complexity of parsing HTTP, and the constrained environment (i.e. running on bare metal), I think its a good fix.