adafruit / Adafruit_CircuitPython_HTTPServer

Simple HTTP Server for CircuitPython
MIT License
46 stars 30 forks source link

Ensure the headers are not modified in HTTPResponse #27

Closed spovlot closed 1 year ago

spovlot commented 2 years ago

Fix for issue #26 which was caused by the passed in headers dict getting modified for the response. Then the calling program reused the headers in subsequent calls. Thanks to @dhalbert and @anecdata for assistance on Discord.

mandar1jn commented 2 years ago

as the author of #26 I can confirm this fixes the content length. And as far as I can see, the capitalization issue too

anecdata commented 2 years ago

Functionally, it shouldn't matter, but should we be consistent between request and response in the use of case for headers?

spovlot commented 1 year ago

Functionally, it shouldn't matter, but should we be consistent between request and response in the use of case for headers?

The HTTP Standard states that header names are case-insensitive - https://www.rfc-editor.org/rfc/rfc9110.html#section-5.1-3 .

The issue #27 manifested itself as a case issue. But I think that was a side effect related to the overwriting of the passed in object.

FoamyGuy commented 1 year ago

agree with @spovlot as well that changing the dictionary values are the root cause of the issue noted and the fix from this change. case consistency could be discussed and / or changed in the future still independent from this fix.