Left here for archival purposes.

User avatar
By MK1888
#9600 This is a possible bug. I'm not sure.

I put an index in the "receive" handler for my simple web server and noticed that some of the payloads are just a single carriage return (and linefeed I guess). Seems like those should be filtered out before the handler. It might be an issue with the client sending over multiple carriage returns? Maybe trim all trailing "\r\n"?

Code: Select allwifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
ip = wifi.sta.getip()
print(ip)
r = 0
s = 0
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
  conn:on("receive",function(conn,payload)
    print("r: "..r)
    print(payload)
    r=r+1
    page = "<!DOCTYPE html><html><body><br/><br/>"
          .."<h1>Receive count: "..r.."</h1>"
          .."<br/><h1>Sent count: "..s.."</h1></body></html>"
    conn:send(page)
  end)
  conn:on("sent",function(conn) s=s+1 conn:close() end)
end)


(And if you have Verizon and make the client request from your mobile phone you'll see their evil zombie cookie.)