BaConServer request stdin
Jul 16, 2021 11:53:27 GMT 1
Post by rikky on Jul 16, 2021 11:53:27 GMT 1
There are two things left with the BaConServer.
One is not important.
bacon version 3.4.1 gives an environment variabele SSH_CLIENT containing the ip address of the client.
In version 3.4.2 this variable is gone.
Since this variable is only useful to be able to block spammers and hackers, and since REAL spammers and hackers can spoof this, I consider it as something luxury, since it provides a fake security.
The second one is more important, but has never been implemented in bacon.
So it is a request.
If you upload a file to your server the data from the file is send via stdin.
Don't ask me how this is possible, I do not have a clue.
But Apache works with the cgi program from the following thread .
Basically, I can send a file to my apache Server via the above program with :
The BaConServer however is not capable yet.
curl -F 'data=@/path/to/something' localhost:8080 to the below BaConServer to see what I mean:
Thanks,
Rik.
One is not important.
bacon version 3.4.1 gives an environment variabele SSH_CLIENT containing the ip address of the client.
In version 3.4.2 this variable is gone.
Since this variable is only useful to be able to block spammers and hackers, and since REAL spammers and hackers can spoof this, I consider it as something luxury, since it provides a fake security.
The second one is more important, but has never been implemented in bacon.
So it is a request.
If you upload a file to your server the data from the file is send via stdin.
Don't ask me how this is possible, I do not have a clue.
But Apache works with the cgi program from the following thread .
Basically, I can send a file to my apache Server via the above program with :
curl -F 'data=@/home/pi/radio2.cfg' http://192.168.1.40/upload
The BaConServer however is not capable yet.
curl -F 'data=@/path/to/something' localhost:8080 to the below BaConServer to see what I mean:
' Define HTTP constants
CONST New$ = CHR$(13) & NL$
CONST Sep$ = CHR$(13) & NL$ & CHR$(13) & NL$
CONST ip$ = "localhost"
CONST port$ = "8080"
LOCAL i
LOCAL content_length$
LOCAL stndin
LOCAL toggle
PRINT "Connect from browser '",ip$,":",port$,"'."
OPEN ip$ & ":" & port$ FOR SERVER AS mynet
WHILE 0=0
handle = ACCEPT(mynet)
RECEIVE data$ FROM handle
PRINT "''''''''''''''''''''''''''''''''''''''''''''''"
PRINT "data : " & data$
IF INSTR(data$,"Content-Length: ") THEN
content_length$ = CHOP$(INBETWEEN$(data$,"Content-Length:",NL$))
PRINT
PRINT "content_length$: " & content_length$
PRINT
PRINT "STDIN:"
FOR i = 1 TO VAL(content_length$)
stndin = WAIT(STDIN_FILENO, 50)
IF stndin !=0 THEN toggle = 1
IF NOT(toggle) AND i>10 THEN BREAK
PRINT STR$(stndin) , " ";
NEXT i
PRINT
IF NOT(toggle) THEN PRINT "No data received."
ELSE
END IF
SEND "HTTP/1.1 200 Ok" & New$ TO handle
SEND "Server: BaCon webserver" & New$ TO handle
SEND "Content-type: text/html; charset=UTF-8" & Sep$ TO handle
SEND "<HTML>" TO handle
SEND "Hello BACON World" TO handle
SEND "</HTML>" TO handle
SEND NL$ TO handle
CLOSE SERVER handle
PRINT "''''''''''''''''''''''''''''''''''''''''''''''"
PRINT
WEND
CLOSE SERVER mynet
Thanks,
Rik.