gnet-io / gnet-examples

Examples of gnet
MIT License
245 stars 77 forks source link

HTTP parser should be created for each request #27

Closed binarylogic closed 3 weeks ago

binarylogic commented 3 weeks ago

In the example, the wildcat HTTP parser is created on connection open and reused for each request. This doesn't reset the parser's state between requests, which could result in it returning the incorrect value. For example, the ContentLength method is cached and not reset. Am I missing something?

panjf2000 commented 3 weeks ago

The wildcat HTTP parser ought to be connection-wide, check out how the author uses it.

That being said, I think you're right about the issue of caching ContentLength, I'm going to take a speculation and say that the author might have misinterpreted the concept.

We need to fix this issue. Good catch on this, thanks!