by Arturo Lopesoria » Tue Feb 20, 2024 11:52 pm
Hello everyone.
I am a FWPPC user but now I have been making small leaps towards Android.
I use uhttpd.exe server
(v.0.4.4 FIXED_THREADS from (c)2009 by Francesco Saverio Giudice)
It WORKED very well for me when I used it to generate the HTML to the Client, serving as a simple and easy Front-End and Back-End.
NOW THE CHALLENGE IS DIFFERENT. The NEED NOW is:
1.- The Front-End must be separated from the Back-End. I do not require the server-side PRG-CGI module to generate anything from the front-end (HTML), the Client will take care of that.
2.- I do not require SSL or MultiThreads since it is a TRIVIAL local website between a PC and one or two Android Devices.
3.- The Client and the server should be able to communicate via $Ajax, HttpRequest, Fetch-Api or perhaps WebSocket?
I'M STILL TRYING WITH UHTTPD
A.- For the BACK-END SERVER side (CGI Module) I use a prg compiled as cgi, for now very simple and simple, configured to receive requests and respond to requests. It reads the Request and accordingly generates the responses that are data from .dbf tables, which reside on the PC and at that point the prg program hard-coded opens tables, and generates responses either in array, json or hash, whichever is most compatible with the scenario.
B.- On the FRONT-END CLIENT side I use an html-javascript-jQuery APP encapsulated using CORDOVA to run in an ANDROID webview. That is, it is responsible for generating all the HTML for the user interface.
For this I based and adapted ideas from JMG. (Robert)
CURRENT SITUATION:
I have not achieved communication, my first approach is the simplest, I make an $Ajax request from the Client side and the server receives it, but when generating the response it violates the CORS rules, generating the error:
Access to XMLHttpRequest at 'http://192.168.1.110/cgi-bin/menu_jmg.hrb?qry=ASKING_SIMPLE_TEXT'
from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Which means it doesn't find the appropriate SERVER side headers uhttpd/CGI Module
PROBLEM:
I require to be able to change the headers either in the CGI module or perhaps in the uhttpd.
I can't find how to make uhttpd respond in any way other than HTML and get the "Access-Control-Allow-Origin *" header in.
It always responds with fixed headers by default.
I have also not been able to compile the uhttpd that is included in:
harbor\core\extras\httpsrv and maybe from there use the insert header functions that I see in the sources. But I still don't even know if I'm going down that path right.
Get uhttpd to respond in some way that supports $Ajax, HttpRequest(), or Fetch-API communication.
I don't dare use Mod-Harbour for this either. Because?
- I have not seen how to use .HRBs instead of .PRGs from Mod-Harbour
- I found it TOO ROBUST for such a simple need.
Any ideas or suggestions for this small scenario of:
Data exchange between PC and Android device on the same local network via WiFi. ?
Arturo LS
Arturo LS