Skip to content
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

301/302 Redirects, FormData files, Cookies, Token authentication #67

Merged

Conversation

michalpokusa
Copy link
Contributor

@michalpokusa michalpokusa commented Aug 28, 2023

Despite multiple new features, the overall API itself didn't change much. I believe theese changes, if it comes to that, should be released as 4.x.0 and not 5.0.0.

⭐ Added:

  • Token authentication class, works the same way as Bearer, but with "Token ..." prefix
  • Added MOVED_PERMANENTLY_301 and FOUND_302 Status objects
  • Headers got new methods: get_directive() and get_parameter(), add and set
  • Request.cookies for retrieving and cookies parameter for setting in all Response-like classes
  • Added docs and example for cookies usage
  • Added request.form_data.files that uses new Files and File classes for representing files uploaded using multipart/form-data

🪛Fixes:

🛠️ Updated/Changed:

  • Redirect got new preserve_method parameter, which allows it to switch between 301, 302, 307 and 308
  • Redirect got new status parameter, which allow for manual status code setting
  • Updated docs and example for Redirect
  • Debug message after sending response now contains elapsed time of request processing
    e.g. 192.168.0.103 -- "GET /index.html" 242 -- "200 OK" 154 -- 182ms
  • Updated docs for FormData
  • Fixed typing for QueryParams, FormData and Headers, especially in get() and get_list()
  • EDIT1: Server.serve_forever now accepts poll_interval parameter which adds delay between calling .poll()
  • EDIT2: Changes in FormData.__init__() for edge cases, e.g. when there is no Content-Type header in POST request
  • EDIT3: Request.json() can now be accessed in PUT, PATCH and DELETE requests

🏗️ Refactor:

  • Moved _IFieldStorage to interfaces.py, also added _IXSSSafeFieldStorage version of interface that enables encoding HTML entities
  • Both QueryParams and FormData implement _IXSSSafeFieldStorage
  • Headers now implements _IFieldStorage and does not store original case of header names, functionally it is the same
  • Redone parsing multipart/form-data form data
  • Simplified parsing of request header bytes

I hope I included everything.

@michalpokusa michalpokusa force-pushed the redirect-301-302-token-form-files-cookies branch from 8edcd1b to 8c16b27 Compare August 29, 2023 17:14
@michalpokusa michalpokusa marked this pull request as ready for review August 31, 2023 20:59
@michalpokusa michalpokusa force-pushed the redirect-301-302-token-form-files-cookies branch from 6858cef to 4ec080e Compare September 1, 2023 05:59
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

I tested as much of the new features and fixes as I could on a combination of Metro S3, and Feather S3 TFT both on 9.0.0 latest release from S3.

Thank you for all of the improvements!

@michalpokusa
Copy link
Contributor Author

@FoamyGuy Thank you for testing and review, I believe the PR is now ready to be merged and released as 4.4.0.

Some time ago there was also an issue about a link in release, seems it was not closed with previous release #65

@FoamyGuy FoamyGuy merged commit 4042554 into adafruit:main Sep 8, 2023
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Sep 8, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 6.0.1 from 6.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#181 from dhalbert/remove-wsgiserver-completely

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.12.1 from 3.12.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#115 from kattni/eyespi-beret

Updating https://github.com/adafruit/Adafruit_CircuitPython_HID to 5.4.0 from 5.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_HID#116 from michalpokusa/layout-write-delay

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 4.4.0 from 4.3.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#67 from michalpokusa/redirect-301-302-token-form-files-cookies

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
@michalpokusa michalpokusa deleted the redirect-301-302-token-form-files-cookies branch October 26, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants