-
Notifications
You must be signed in to change notification settings - Fork 31
Case insensitive HTTPHeaders, HTTPResponse context manager and some fixes #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case insensitive HTTPHeaders, HTTPResponse context manager and some fixes #29
Conversation
@michalpokusa Any thoughts on this 404 issue? #28 (comment) I don't see anything obvious in this PR that would have affected it. Maybe it came in with the refactor and just wasn't noticed until now. Worth a separate issue? |
Working on it, also I see that other PR was merged and there are merge conflicts, so I will fix both before proceeding |
After merging recently updated I decided to modify the Also fixed the 404 problem in #28. Using context managers all of the examples below are allowed. |
That for sure looks a lot cleaner. Thanks for doing that |
In the meantime I updated examples to new "context manager way" of serving response. Did some testing on my own and I believe that it works as it should. Also I added raising error if someone tries to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested my use cases, and everything seemed to work fine, with exception of sending html in chunked mode.
@anecdata Could be please take a look at the current state of this PR. I believe there is everything I wanted to add and that it is ready to be merged. In the c758e51 commit I also "included" the #30. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested file serving, GET, POST, a couple of MIME types, custom HTTP status code, chunked and non-chunked response bodies, multi-byte characters in response, accessing the client address.
This is a pretty large change in API, so we should change the version number accordingly.
This looks good to me, one minor thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @michalpokusa. And thanks @bill88t for #30 included here.
This should be 2.0.0 if there are incompatible API or use changes. A major version change means a code rewrite is needed. |
If I understand correctly, the code stays the same, only tag changes, so no further edits are needed on my part to make it 2.0.0 |
Closing #30 then. Thanks for taking care of it! |
Right, when I or whoever makes a release, it will be 2.0.0. There are incompatible API or use changes, right? |
Yes, instead of returning HTTPResponse instance in route handlers, the function should call a method on HTTPResponse, so all handlers need to be slightly modified, but still. |
Great - I will make a release now. I only found one use of this library in the Learn guides: |
Thanks for merging. Yes, there will be a small change in |
Maybe if Liz still has it set up, it would be easy for her to test. I have a Pico W and could test the routes, but I don't have the peripherals, so I'd stub out the I/O (possibly introducing or masking an issue). Any network code written for |
If you either of you could make a draft PR, I'll test it by simplifying or setting up the base hardware. Thanks. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 2.0.0 from 1.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#29 from michalpokusa/httpheaders-and-some-fixes Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Added separate class for HTTP headers, that allows accessing headers using case-insensitive names.
Also, changed some docstrings the were unclear and one that was misleading as it was inconsistent with the code.
Changed the order of Docs References, so that the most "important" ones are on the top, with enums and dataclass-like classes below.
Updated library version to 1.1.0 in sphinx configuration file.
Fixes #26
Fixes #28