v icon indicating copy to clipboard operation
v copied to clipboard

x.vweb: add configuration options and handle incomplete requests

Open Casper64 opened this issue 1 year ago • 4 comments

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.

Casper64 avatar Feb 18 '24 22:02 Casper64

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

Casper64 avatar Feb 20 '24 20:02 Casper64

It shouldn't be a problem to cache the header until it's completely read.

JalonSolov avatar Feb 20 '24 21:02 JalonSolov

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

Casper64 avatar Feb 20 '24 21:02 Casper64

Now that x.vweb has become veb (and x.vweb is deprecated), perhaps this should be adapted to veb if needed.

JalonSolov avatar Aug 28 '24 00:08 JalonSolov