lasselukkari / aWOT

Arduino web server library.
MIT License
283 stars 41 forks source link

Request Headers #144

Open tedhenry100 opened 1 year ago

tedhenry100 commented 1 year ago

Hi,

I've been using aWOT in a new project and development is going well. Thanks for your work developing aWOT.

I would like to have access to the Host header value of HTTP requests.

I see that there is the following method to configure the aWOT application to put a header value into a buffer as a request is processed.

void header(const char* name, char* buffer, int bufferLength);

The issue I'm having with this is that as requests come in, they new request's host value clobbers the previous request's host value in the buffer. This works ok in a single threaded environment but it seems like it would be much safer if the aWOT request object would hold the header values for the particular request.

Would it be possible to add something like the following to the aWOT application instead?

void header(const char* name, int bufferLength);

This would tell the aWOT application to dynamically allocate a buffer of the specified length as part of each request object and then store the header value in buffer. The middle wear could then get the header values from the aWOT request object instead of having a separate, unconnected buffer holding the value.

lasselukkari commented 1 year ago

I have recently been working on version 4 of the library, which will implement this change. I'm mostly done, but I need to update the documentation before it gets released.

Out of curiosity, could you share the multithreaded environment you are working with? Just for fun I have been running some tests on a x86 environment where i have ported the Arduino Client interface to use standard blocking sockets. On my 10 years old Macbook I'm getting 80000 req/s with a naive hello world example.

tedhenry100 commented 1 year ago

Wow! I'm glad I asked about this. Version 4 will be a great advancement for the aWOT library! :-)

I'm not currently using a multithreaded environment but programming in style that depends on a single threaded environment makes me nervous. I think programming so that the code is ready to be used in a multithreaded environment is safer, more flexible, and easier to understand.

Thanks again for your hard work on aWOT. I'm looking forward to version 4!