Skip to content

Error condition when the connection will be closed by the server while reading the response #25

Closed
@amotl

Description

@amotl

Dear people of Adafruit,

thanks a bunch for taking over from urequests and giving that baseline implementation so much love within your Adafruit_CircuitPython_Requests module. We are about to switch over to your implementation within our Terkin Datalogger.

It came to our attention that the baseline implementation might suffer from a minor issue manifesting in a specific error condition. The user kjm reported on the Pycom user forum at [1] that when the server would close the connection while reading the socket, the module will croak like

OSError: [Errno -76] MBEDTLS_ERR_NET_RECV_FAILED
AttributeError: NoneType object has no attribute close

within the Response.content() method [2]. That will also apply to this implementation. So, I would like to suggest to replace the two lines [3] with just self.close().

With kind regards,
Andreas.

[1] https://forum.pycom.io/topic/5755/micropython-error-trail-confusing-me
[2] https://github.com/micropython/micropython-lib/blob/829f53dc9ea633f3a906cc078027fe7c5248b04e/urequests/urequests.py#L16-L24
[3] https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/v1.1.0/adafruit_requests.py#L115-L116

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions