-
Notifications
You must be signed in to change notification settings - Fork 55
wget Does not check for validity of headers prior to use #51
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
Comments
Proposed solution:
|
That looks like a good solution; please submit a PR |
What's the HTTP status response code when the service is polled too frequently? I noted lack of checking there in #37 |
Strictly speaking the exception text should be An absent |
So yes, it turns out the issue was a little bit more complicated than first look. I made a hack, not a fix. |
will you go on with wget or should I finde an other way to download a file to my PyPortal ? |
Also reported on Discord. It appears that this may be due to server responses that do not contain a content-length HTTP header. In that case, the client should just read until there are no more bytes (the server has closed the connection). The lower-level Requests library handles this case by setting |
I've got chunked support in my pending Adafruit_Requests library as well. https://github.com/tannewt/Adafruit_CircuitPython_Requests/tree/http11 |
@anecdata The connection close is an interesting rather old skool case, they are rare nowadays because making a new connection is expensive, particularly with TLS. Perhaps simple http servers are generating them, do you have a full dump of request and response headers? It's down as the fifth and final method in preference order in the 1.1 spec: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 |
I'm mainly going by the
transfer-encoding (or are simply HTTP/1.0 servers). Contrast with handling of Key error in Requests library (link above). So this one is probably recoverable with a change to the library. I'll ask in Discord to see if we can get server headers. Client headers should just be the default CircuitPython GET HTTP/1.0 headers:
|
In the event of an HTTP error, such as polling Adafruit IO api too often, the statement
content_length = int(r.headers['content-length'])
at line 638 is not valid which causes an unhandled exception.The text was updated successfully, but these errors were encountered: