Commit graph

29 commits

Author SHA1 Message Date
foxy82
1063a01ee4
Fix infinite loop when requesting too quickly
On the Pico W we can get in an infinite loop if we request pages too quickly. This is because we get an OSError 32 Broken Pipe back from which we can't recover.
I've made it so any of the unexpected errors will be re-raised.

Fixes this issue:
https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/issues/44
2023-04-03 12:10:28 +01:00
Maciej Sokołowski
4e63771c3b
Expose buffer_size in response.send_file, adjust default to match the one in server 2023-01-20 09:57:19 +01:00
Radomir Dopieralski
20f50ac385 Allow sending raw bytes in the response
We now only encode the body if it has an encode method, which usually
means it's a string. This allows passing bytes, bytearray or memoryview.

I also changed the logic for sending a chunk, that avoids copying the
data unnecessarily. I believe this also fixes a bug, where the size of
unencoded chunk was sent, in characters, instead of encoded size, in
bytes.
2023-01-11 21:54:05 +01:00
michalpokusa
d14a13a1c4 Fix: Content type not setting properly 2022-12-28 05:51:40 +00:00
michalpokusa
f0b61a721f Prevented from calling .send() multiple times and added deprecation error if handler returns HTTPResponse 2022-12-26 01:52:39 +00:00
michalpokusa
4b61d74e1f Fix: Missing chunk length in ending message due to .lstrip() 2022-12-26 01:21:51 +00:00
michalpokusa
c222d09a71 Changed send_chunk_body to send_chunk for unification 2022-12-24 06:26:23 +00:00
michalpokusa
a12d4abbc6 Minor changes to docstrings 2022-12-23 18:57:28 +00:00
michalpokusa
2ca4756bac Changed HTTPResponse to use context managers 2022-12-23 11:57:27 +00:00
michalpokusa
00d3247825 Refactor for unifying the HTTPResponse API 2022-12-23 11:55:57 +00:00
michalpokusa
c1d2f55c46 Merge remote-tracking branch 'origin/main' into test 2022-12-23 11:54:37 +00:00
michalpokusa
aeb95a2932 Encoding body only once when constructing response bytes 2022-12-20 01:02:51 +00:00
michalpokusa
be20bb12e7 Black format changes 2022-12-19 21:15:05 +00:00
michalpokusa
d3adfd824c Fixed wrong content length for multibyte characters 2022-12-19 20:26:24 +00:00
michalpokusa
f1878b3ace Replacing dict with HTTPHeaders in other modules 2022-12-19 20:24:31 +00:00
paul-1
4768bbd20a Add Chunked Encoding to minimize memory usage for
large dynamic html pages.
2022-12-14 20:00:41 -05:00
paul-1
e66cfbfcb5 Add Cache-Control to headers. 2022-12-14 19:58:14 -05:00
Scott Povlot
7249a5ec76
Ensure the headers are not modified 2022-12-02 12:52:21 -05:00
michalpokusa
4a1a3a129d Added option to pass status to HTTPResponse as tuple, overwrited eq method on HTTPStatus 2022-11-19 13:45:53 +00:00
michalpokusa
0fe7bd7453 Fix: Wrong typing and return type in HTTPResponse._construct_response_bytes 2022-11-18 00:26:50 +00:00
michalpokusa
6585d3f709 Resolving rest of pylint and black errors 2022-11-14 00:34:05 +00:00
michalpokusa
21e20b6041 Preparing code for docs generation, black formatting, updating examples 2022-11-13 23:26:25 +00:00
michalpokusa
41edff8ceb Added CommonHTTPStatus 2022-11-13 22:10:05 +00:00
michalpokusa
132d36c8ca Added passing HTTPResponse headers to file response 2022-11-13 14:56:46 +00:00
michalpokusa
4b3e4f9866 Refactor of MIMEType 2022-11-13 13:19:02 +00:00
michalpokusa
e06d0cd29c Small changes across files, comments, typing 2022-11-13 12:15:31 +00:00
michalpokusa
9b49df8733 Unified root to root_path across all files 2022-11-13 09:58:09 +00:00
michalpokusa
9a021bd9ba Refactor of HTTPResponse, addition of new attributes 2022-11-13 09:52:23 +00:00
michalpokusa
6892a93535 Splitted adafruit_httpserver into separate files 2022-11-12 19:47:50 +00:00