v
v copied to clipboard
x.vweb: add configuration options and handle incomplete requests
This pr adds a Config struct to x.vweb to change the default behaviour of vweb.
When vweb encounters an incomplete request it will now wait until a timeout occurs for new data instead of immediately closing the connection. The Config struct contains an option to limit the number of incomplete requests per connetion that are allowed before the connection is closed.
The Config struct also adds the option to limit the maximum HTTP header size and the maximum body length for a request.
io.BufferedReader will erase any existing data from its buffer when it refills. Another solution is needed to store the already read data from an incomplete request. Or a custom "StringReader" which keeps the read data in the buffer
It shouldn't be a problem to cache the header until it's completely read.
It shouldn't be a problem to cache the header until it's completely read.
No, but the problem is that I can't access the data to cache it. And can't read the data first, because the net library only takes a buffered reader has argument when parsing only the request headers.
So I'll probably need to add another function as well
Now that x.vweb has become veb (and x.vweb is deprecated), perhaps this should be adapted to veb if needed.