What protocols or libraries are available to do the following using an Arduino of some type:-
This question follows on from Are there any sophisticated web servers for the Arduino?. I'm specifically thinking of dynamic pages, not just coughing up static resources from an SD card. Is there anything out there more refined than the bog standard Ethernet library that ships with the IDE?
Examples might be understanding semantic URLs and automatic parsing of queries /fragments /headers. Perhaps load throttling for when a bot crawls the URL. BASIC authentication? I take my initial thoughts for requirements by looking at the Servlet spec. I added the picture because it looks nice and I have the same hair style.
Before someone kindly points out that a WebLogic instance might not fit on an Arduino, I'm wondering what would? Any ideas?
Well for dynamic content I mean just that. Say the ADC levels in the IDE example, or sending a RAW image. So the Arduino does stuff programmatically and then sends it over the wire in response to a GET or POST request. All the parameter parsing is tedious and gets even more so when the hackers start passing malformed requests. I get a lot of GET //phpmyadmin/scripts/setup.php with the double slash. Or t3 12.2.1 which doesn't even have a method. How did that get in by the way? Something more robust is required if the Arduino's internet facing. So I'm after:-
I guess it's a form of RPC /IPC /CGI protocol over HTTP. Or the way data from one server is embedded into a page generated on another server. Anything like that? Anything at all? Even remotely?
PS. Apache httpd (2.4.29) is currently about 15MB of C source. So it's clearly possible.
I'm routinely building up html pages line by line incorporating all kinds of sensor data on the ESP8266. It's dead easy to do. A bit of a chore of course but it works just fine. Do remember to use the F() macro to put all those strings in flash or your 80 kB variable space runs out very very quickly
A next step is going to be to make it more dynamic - but that's going to require things like JavaScript on the browser side (there's a lot to "dynamic pages" that is done browser side in the first place).
Okay thanks for the heads up. I hadn't realised that the Arduino was out of fashion. Strange to hear that on the official Arduino forum. I'm reminded of a quote; “Trendy is the last stage before tacky.” - Karl Lagerfeld
Seems to me that there's quite a gap in the market then. Your ESP8266 looks trendy but wireless is quite restrictive sometimes and I don't often see the point of it unless the entire project is wirelessly powered. And I don't see the point of the RPi either. It's a poor compromise between a PC and a micro controller. I don't know why I should need 35,000 packages including a word processor,image editor and the JDK to control an LED over Ethernet.
I appreciate that all my HTTP requests can be parsed as of now. That really underpins my question. All that request processing takes a great deal of code if the Arduino were to be internet facing (however not lots of RAM). It seems that you're saying people just reinvent the wheel over and over. I'm willing to bet that frequently it ends up being a bit square.
Could the URL processing part of the ESP8266WebServer library be extracted and incorporated into an Ethernet library fork? And any other optimisations like robustness or error handling?
cossoft:
Could the URL processing part of the ESP8266WebServer library be extracted and incorporated into an Ethernet library fork?
Probably. I'm not stopping you.
Anyway, as said in #12, it's a quite simple process to write code to parse those strings. Been there done that. It's of course convenient that it's built in to the server code, so you can just query it. POST strings are a bit more work than GET strings as the data is in the headers rather than in the URL, but still not rocket science.
The best part of the server code is that it calls functions based on the URL. So you can have a function for "/", one for "/led", one for "/alarm" and even one for "/spray_the_cat".