1Reading POST vars
This example will show reading POST vars. These are basically the same as GET vars but using WS_POST() instead of WS_GET()
Bitty HTTP stores POST vars in a block of RAM as the headers are processed (just after the GET vars). This means it needs to know the names of all the POST vars before the page is requested. This is done by filling in the struct WSPageProp.Posts variable when the page properties are requested.
The Posts property (just like the Gets) is an array of pointers to strings with the last one being set to NULL to mark the end of the list. This list is scanned when the page is requested and the value of any vars in this list are added to a RAM array.
You then call WS_POST() to get the value that was saved (or NULL if it wasn't found).
Using things this way means a low memory foot print as we only remember vars that we are going to pull out later.
The file server is changed to provide a form on the root page and a new page to display the values from the form.
We add a list of POST vars that we may want to read when processing a page later. We end the list with NULL to mark the end of the list. The code will loop though this list looking for a NULL entry to stop at.
When a match is made the value of the var will be copied to an internal RAM buffer.
A new page has been added called /Display.html that will display what the user has typed into the form from the root page. This includes a pointer to the PostArgs as the 5'th argument. If you wanted to use both GET and POST vars you would provide to different arrays (one for POSTand one for GET vars).
This now just outputs a basic form with a get method asking the user for their name and going to /Display.html.
File_Display() uses WS_POST() to read out the get vars from internal RAM. You call it with the name of the POST var to read. This name also has to be in the PostArgs array as well.
If WS_POST() does not find the var (because it wasn't passed in) it returns NULL.
It WS_POST() does find the var then it returns a string pointer to the value that was read.