File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 5555
5656import errno
5757
58+ # CircuitPython 6.0 does not have the bytearray.split method.
59+ # This function emulates buf.split(needle)[0], which is the functionality
60+ # required.
61+ def _buffer_split0 (buf , needle ):
62+ index = buf .find (needle )
63+ if index == - 1 :
64+ return buf
65+ return buf [:index ]
66+
5867
5968class _RawResponse :
6069 def __init__ (self , response ):
@@ -220,7 +229,7 @@ def _readinto(self, buf):
220229 # Consume trailing \r\n for chunks 2+
221230 if self ._remaining == 0 :
222231 self ._throw_away (2 )
223- chunk_header = self ._readto (b"\r \n " ). split ( b";" , 1 )[ 0 ]
232+ chunk_header = _buffer_split0 ( self ._readto (b"\r \n " ), b";" )
224233 http_chunk_size = int (bytes (chunk_header ), 16 )
225234 if http_chunk_size == 0 :
226235 self ._chunked = False
You can’t perform that action at this time.
0 commit comments