thttpd - web daemon software
This commit is contained in:
parent
25c190d5e0
commit
060156b78f
|
@ -0,0 +1 @@
|
||||||
|
Copyright (C) 2011-2012 Johan Ceuppens
|
|
@ -0,0 +1 @@
|
||||||
|
thttpd : a client-server web system
|
|
@ -0,0 +1,12 @@
|
||||||
|
version 0.1
|
||||||
|
* working connection with a few commands (telnet localhost 1025 and
|
||||||
|
* type in MAIL\r\n or QUIT\r\n
|
||||||
|
* tdaemon.scm script which can be run in scsh to (run-daemon-child staterecord)
|
||||||
|
* "rc" alike tforks.scm, tserver.scm tclient.scm which contain tell-client and ask-server methods.
|
||||||
|
* tforks.scm contains record and daemon to be spawned by e.g. init or daemontools
|
||||||
|
* and uses fork-and-forget with 10 commands per session.
|
||||||
|
* old/ code directory
|
||||||
|
* daemon state record (port, host, etc.)
|
||||||
|
* telnetable daemon
|
||||||
|
* daemon state record
|
||||||
|
* dispatch object second executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
- This is a http daemon
|
||||||
|
Basically run scsh, ',open records sockets'
|
||||||
|
telnet localhost 8080
|
||||||
|
for asking the server.
|
||||||
|
|
||||||
|
mailer daemon command history:
|
||||||
|
GET
|
|
@ -0,0 +1,39 @@
|
||||||
|
;;; load.scm - a scheme web daemon script
|
||||||
|
;;;
|
||||||
|
;;; Copyright (c) 2011-2012 Johan Ceuppens
|
||||||
|
;;;
|
||||||
|
;;; All rights reserved.
|
||||||
|
;;;
|
||||||
|
;;; Redistribution and use in source and binary forms, with or without
|
||||||
|
;;; modification, are permitted provided that the following conditions
|
||||||
|
;;; are met:
|
||||||
|
;;; 1. Redistributions of source code must retain the above copyright
|
||||||
|
;;; notice, this list of conditions and the following disclaimer.
|
||||||
|
;;; 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
;;; notice, this list of conditions and the following disclaimer in the
|
||||||
|
;;; documentation and/or other materials provided with the distribution.
|
||||||
|
;;; 3. The name of the authors may not be used to endorse or promote products
|
||||||
|
;;; derived from this software without specific prior written permission.
|
||||||
|
;;;
|
||||||
|
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
;;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
;;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
;;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
;;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
;;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
(load "thttpdaemon.scm")
|
||||||
|
|
||||||
|
(define rc (make-thttpd-daemon-record
|
||||||
|
"localhost" ;; virtual host
|
||||||
|
8080
|
||||||
|
#f))
|
||||||
|
|
||||||
|
(run-daemon-child-http rc)
|
||||||
|
|
||||||
|
(display "http-daemon ends.")
|
||||||
|
(newline)
|
|
@ -0,0 +1,8 @@
|
||||||
|
(define-interface thttpd-interface
|
||||||
|
(export
|
||||||
|
run-daemon-child-http))
|
||||||
|
|
||||||
|
(define-structure thttpd
|
||||||
|
tmail-interface
|
||||||
|
(open scheme)
|
||||||
|
(files thttpdaemon load))
|
|
@ -0,0 +1,12 @@
|
||||||
|
(define-package "thttpd"
|
||||||
|
(0 1)
|
||||||
|
((install-lib-version (1 3 0)))
|
||||||
|
(write-to-load-script
|
||||||
|
`((config)
|
||||||
|
(load ,(absolute-file-name "packages.scm"
|
||||||
|
(get-directory 'scheme #f)))))
|
||||||
|
(install-file "README" 'doc)
|
||||||
|
(install-file "NEWS" 'doc)
|
||||||
|
(install-string (COPYING) "COPYING" 'doc)
|
||||||
|
(install-file "packages.scm" 'scheme)
|
||||||
|
(install-file "tserver.scm" 'scheme))
|
|
@ -0,0 +1,80 @@
|
||||||
|
;;; thttpdaemon.scm - a scheme web daemon
|
||||||
|
;;;
|
||||||
|
;;; Copyright (c) 2011-2012 Johan Ceuppens
|
||||||
|
;;;
|
||||||
|
;;; All rights reserved.
|
||||||
|
;;;
|
||||||
|
;;; Redistribution and use in source and binary forms, with or without
|
||||||
|
;;; modification, are permitted provided that the following conditions
|
||||||
|
;;; are met:
|
||||||
|
;;; 1. Redistributions of source code must retain the above copyright
|
||||||
|
;;; notice, this list of conditions and the following disclaimer.
|
||||||
|
;;; 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
;;; notice, this list of conditions and the following disclaimer in the
|
||||||
|
;;; documentation and/or other materials provided with the distribution.
|
||||||
|
;;; 3. The name of the authors may not be used to endorse or promote products
|
||||||
|
;;; derived from this software without specific prior written permission.
|
||||||
|
;;;
|
||||||
|
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
;;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
;;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
;;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
;;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
;;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
(define (eoln) (string #\newline))
|
||||||
|
(define (servermsg) (string "::thttpd-msg::"))
|
||||||
|
(define (errormsg) (string "::thttpd-error::"))
|
||||||
|
(define aspect-content "Content-Type: text/plain;charset=utf-8");; (string #\newline)))
|
||||||
|
(define :thttpd-daemon-record
|
||||||
|
(make-record-type 'thttpd-daemon-record
|
||||||
|
'(hostname port sock)))
|
||||||
|
(define make-thttpd-daemon-record
|
||||||
|
(record-constructor :thttpd-daemon-record
|
||||||
|
'(hostname port sock)))
|
||||||
|
|
||||||
|
(define thttpd-hostname (record-accessor :thttpd-daemon-record 'hostname))
|
||||||
|
(define thttpd-port (record-accessor :thttpd-daemon-record 'port))
|
||||||
|
(define thttpd-sock (record-accessor :thttpd-daemon-record 'sock))
|
||||||
|
|
||||||
|
|
||||||
|
(define (run-daemon-child-http rec)
|
||||||
|
(let ((*hostname (thttpd-hostname rec))
|
||||||
|
(*port (thttpd-port rec))
|
||||||
|
(*socket (thttpd-sock rec))
|
||||||
|
)
|
||||||
|
|
||||||
|
(set! *socket (open-socket *port))
|
||||||
|
|
||||||
|
(for-each display '("Opening listening socket on host : "
|
||||||
|
*hostname
|
||||||
|
" port : "
|
||||||
|
*port
|
||||||
|
(eoln)))
|
||||||
|
((lambda ()
|
||||||
|
(call-with-values
|
||||||
|
(lambda ()
|
||||||
|
(socket-accept *socket))
|
||||||
|
(lambda (in out)
|
||||||
|
;;(let ((in (make-string-input-port in)))
|
||||||
|
(let ((answer (read in)))
|
||||||
|
;;(let ((answer2 (read in)))
|
||||||
|
;;(let ((answer3 (read in)))
|
||||||
|
(for-each display '((servermsg) (symbol->string answer)))
|
||||||
|
(if (symbol? answer)
|
||||||
|
(cond ((eq? 'GET answer)
|
||||||
|
(write aspect-content out)
|
||||||
|
(write (string #\newline))
|
||||||
|
(write "Hello World" out)
|
||||||
|
;;(close-input-port in)
|
||||||
|
;;(close-socket *socket)
|
||||||
|
;;(close-output-port out)
|
||||||
|
)
|
||||||
|
(else ;; + keep-alive
|
||||||
|
(write (errormsg) out))
|
||||||
|
)))))))));;);;)
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
(load "util.scm")
|
(load "util.scm")
|
||||||
(load "trecords.scm")
|
(load "trecords.scm")
|
||||||
(load "tmailbox-load.scm")
|
(load "tmailbox-load.scm")
|
||||||
|
;; You can use e.g. daemontools to restart it everytime
|
||||||
(define (run-daemon-child-mail rec)
|
(define (run-daemon-child-mail rec)
|
||||||
(let ((*hostname (hostname rec))
|
(let ((*hostname (hostname rec))
|
||||||
(*port (port rec))
|
(*port (port rec))
|
||||||
|
|
Loading…
Reference in New Issue