-
Notifications
You must be signed in to change notification settings - Fork 35
204 Fix #213
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
204 Fix #213
Conversation
@@ -102,11 +102,12 @@ class Response: | |||
It is still necessary to ``close`` the response object for correct management of | |||
sockets, including doing so implicitly via ``with requests.get(...) as response``.""" | |||
|
|||
def __init__(self, sock: SocketType, session: "Session") -> None: | |||
def __init__(self, sock: SocketType, session: "Session", method: str) -> None: |
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.
@FoamyGuy This is the only way we can also do the HEAD check (which would also have no content). Are we good with this?
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.
Makes sense to me.
import adafruit_requests | ||
|
||
|
||
@pytest.mark.parametrize( |
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.
These tests, do actual calls to httpbin. We should make sure not to add too many, but this should help us make sure we don't break anything...
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 agree with limiting the use of calls out to 3rd party services in the tests. This one is okay for now, but perhaps it would be good to add a simple httpserver script in the tests dir that the tests can then interact with. That way it can get the same functionality but be more self contained, and not reliant on actual network conditions (I had httpbin returning 503 for a moment which I think would've caused the test to fail).
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.
@justmobilize This did end up causing the test and thus actions check to fail: https://github.com/adafruit/Adafruit_CircuitPython_Requests/actions/runs/15278252260/job/42970208909#step:2:1007
With that in mind I think rather just not have our tests rely on the 3rd party service. If you have a moment and can PR removing this test, or altering it to use a local server please do. I can circle back in a day or two and do it if you don't.
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.
Thank you, this looks good to me. I tested successfully on a Feather ESP32-S3 with slighly modified reproducer from the issue.
@@ -102,11 +102,12 @@ class Response: | |||
It is still necessary to ``close`` the response object for correct management of | |||
sockets, including doing so implicitly via ``with requests.get(...) as response``.""" | |||
|
|||
def __init__(self, sock: SocketType, session: "Session") -> None: | |||
def __init__(self, sock: SocketType, session: "Session", method: str) -> None: |
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.
Makes sense to me.
import adafruit_requests | ||
|
||
|
||
@pytest.mark.parametrize( |
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 agree with limiting the use of calls out to 3rd party services in the tests. This one is okay for now, but perhaps it would be good to add a simple httpserver script in the tests dir that the tests can then interact with. That way it can get the same functionality but be more self contained, and not reliant on actual network conditions (I had httpbin returning 503 for a moment which I think would've caused the test to fail).
Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.13.4 from 2.13.3: > Merge pull request adafruit/Adafruit_CircuitPython_EPD#88 from makermelissa/main Updating https://github.com/adafruit/Adafruit_CircuitPython_INA219 to 3.4.28 from 3.4.27: > Merge pull request adafruit/Adafruit_CircuitPython_INA219#39 from ilario/importerror_i2c Updating https://github.com/adafruit/Adafruit_CircuitPython_INA3221 to 1.2.0 from 1.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_INA3221#8 from BZab/main Updating https://github.com/adafruit/Adafruit_CircuitPython_OPT4048 to 1.0.1 from 1.0.0: > Merge pull request adafruit/Adafruit_CircuitPython_OPT4048#1 from FoamyGuy/use_properties Updating https://github.com/adafruit/Adafruit_CircuitPython_OV5640 to 1.2.8 from 1.2.7: > Merge pull request adafruit/Adafruit_CircuitPython_OV5640#40 from FoamyGuy/saturation_effect_fix Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.4.5 from 1.4.4: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#25 from FoamyGuy/displayio_api_update Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1327 to 1.4.5 from 1.4.4: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1327#27 from adafruit/update-display-modules Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1680 to 2.0.2 from 2.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1680#32 from makermelissa/main Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735 to 1.2.17 from 1.2.16: > Merge pull request adafruit/Adafruit_CircuitPython_ST7735#23 from FoamyGuy/displayio_api_update Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X to 1.2.4 from 1.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_VL53L1X#25 from apzerafa/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Dash_Dis to 3.0.2 from 3.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_Dash_Dis#22 from adafruit/dhalbert-patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.3.0 from 3.2.4: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#220 from cinderblockgames/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 4.1.11 from 4.1.10: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#213 from justmobilize/204-fix Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_OPT4048
Resolves: #210
Looking at requests in Cpython:
requests
usesurllib3
which uses CPythonhttp
in http.client during a
HTTPConnection.getresponse
it callsHTTPResponse.begin
which does the following logic to determine to set the length to 0:This copies this logic and puts it into
_parse_headers
whcih is the closes thing we have.