pico-feedback icon indicating copy to clipboard operation
pico-feedback copied to clipboard

Example code has a unintended potential infinite loop

Open GM-Script-Writer-62850 opened this issue 3 years ago • 0 comments

https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf Page 24 line 50:

# We are not interested in HTTP request headers, skip them
while await reader.readline() != b"\r\n":
     pass

Is is very possible a browser will send a empty request to the pico (that or something else on my network is doing it, but i doubt it)

This could be changed to this, if header==b"" it will be treated as False in the while condition

# We are not interested in HTTP request headers, skip them
header=await reader.readline()
while header and header != b"\r\n":
      header=await reader.readline()

test code samples and output are in this thread:'https://forums.raspberrypi.com/viewtopic.php?t=341192

GM-Script-Writer-62850 avatar Oct 09 '22 01:10 GM-Script-Writer-62850