gnet-io / gnet-examples

Examples of gnet
MIT License
245 stars 77 forks source link

Http-parser have a bug #5

Closed danyalmh closed 2 years ago

danyalmh commented 3 years ago

https://github.com/gnet-io/gnet-examples/blob/4c982ee21cf2cabe5fd581cfd7652b4f1eb29332/examples/http/http.go#L160

req.path = sdata[s:q] req.query = req.path[q+1 : i]

this code in http-parser have a bug, provide this error : ==> panic: runtime error: slice bounds out of range [:30] with length 15

i know you know what is problem ;-)

mircodz commented 2 years ago

Just encountered this issue while browsing through the examples, there's a simple fix:

-req.Path = sdata[s:q]
-req.Query = sdata[q+1:i]
+req.Path = sdata[s:s+q]
+req.Query = sdata[s+q+1:i]
panjf2000 commented 2 years ago

@mircodezorzi Could you open a PR for this?

mircodz commented 2 years ago

Sure :+1: