Hi,
the example on the usage of command-event in -http mode shows how to preprocess the request.
Is it possible to create the response in command-event, and let it be sent to the client directly?
And if not, how would I best solve this problem?
Thanks for your answers,
Ingo
-http construct response in command-event ?
Re: -http construct response in command-event ?
No sure why you would want do this, because newLISP's built-in web server would take care of headers etc. You need the http-conf.lsp only if you want to filter and or modify requests coming in via the 's' parameter - but you could do the following:
start newLISP server like this:
for port numbers < 1000 you would need root permissions depending on the OS.
Because the function in 'command-event returns an empty string, newLISP's internal web server never gets called and the response is sent back by the 'command-event function via port 8080.
Code: Select all
;; contents of http-conf.lsp
(command-event (fn (s)
(print "HTTP/1.0 200 OK\r\n")
(print "Content-Length: 11\r\n")
(print "Content-Type: text/html\r\n\r\n")
(print "Hello World")
""
))
Code: Select all
newlisp httpd-conf.lsp -c -d 8080
Because the function in 'command-event returns an empty string, newLISP's internal web server never gets called and the response is sent back by the 'command-event function via port 8080.
Re: -http construct response in command-event ?
Thank you for the explanation.
My reasoning for asking for this is:
If I'm using a Newlisp webserver, and Newlisp cgi ... why not just load the cgi functions on the start of the webserver? Then I can save the load time on cgi calls.
My reasoning for asking for this is:
If I'm using a Newlisp webserver, and Newlisp cgi ... why not just load the cgi functions on the start of the webserver? Then I can save the load time on cgi calls.