-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add HTTP1.1 support and socket reuse #31
Conversation
Does this need a new version of
|
@FoamyGuy No, it's not fully backwards compatible atm. I'm hoping to get to that today. Specifically, the current iteration doesn't use an IP address for HTTP connections and doesn't set TLS_MODE during |
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.
Looks great, read through it to get a better sense of how the socket pools will work in MiniMQTT. I have a few questions.
examples/requests_advanced.py
Outdated
# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other | ||
# source control. | ||
# pylint: disable=no-name-in-module,wrong-import-order | ||
from secrets import secrets |
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.
May want to add a more verbose try
/except
for users who do not have a secrets.py file on their FS: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/master/examples/esp32spi_aio_post.py#L15
With this version of Requests and: I consistently get:
The older version (Discord version) of Requests generally works, some intermittent errors: |
* Add TLS_MODE to old connect() calls * Provide ip to connect when in HTTP mode
|
Some edge cases. (I'm tracking down why I still get Here's one: Zero-length response bodies should be valid, but try this:
yields some odd behavior, sometimes gets |
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.
Requested changes resolved and looks good.
@anecdata Can you reproduce that with CPython sockets? Sounds like it may be a timeout thing. |
That URL returns right away consistently in browser and python3 on macOS, with header:
If there's another test procedure I can try, please point me in the right direction. It doesn't always exception on CicruitPython, but typically at least once in 5 tries. It may be two separate issues, but with a |
This may be a clue: if I manually shorten the requests timeout in CircuitPython: |
BTW, noticed this the other day and it seems consistent... if a scan isn't done first, oops, I guess that doesn't belong in this PR |
@anecdata Ok, sounds like these are ESP32-S2 wifi related issues, not with this library itself. |
Should I file... 2 issues on circuitpython? |
@anecdata Yes please! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME280 to 2.5.0 from 2.4.3: > Merge pull request adafruit/Adafruit_CircuitPython_BME280#40 from anecdata/relative Updating https://github.com/adafruit/Adafruit_CircuitPython_TLV493D to 1.1.4 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_TLV493D#6 from danaliv/address_kwarg Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.7.0 from 1.6.0: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#31 from tannewt/http11 Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_AirLift
Reusing sockets makes sharing memory easier and keeping the connection open will make them faster.
This PR also moves to a model of passing the socket and ssl implementation into
Session
instead of into the module with a function.json parsing will now happen character-by-character on CircuitPython and lower the peak memory used and the largest allocation size.
It includes legacy compatibility so it shouldn't break anything. Corresponding libraries will benefit more from this when they implement
recv_into
so they don't allocate a new buffer every read.This is draft because I need to: