;; Basic Gemini server ;; ;; Copyright (C) 2022 rick G. ;; ;; This program is free software: you can redistribute it and/or modify it under ;; the terms of the GNU General Public License as published by the Free Software ;; Foundation, either version 3 of the License, or (at your option) any later ;; version. ;; ;; This program is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License along with ;; this program. If not, see . ;;( use-modules (gnutls) ) (use-modules (ice-9 binary-ports) (ice-9 iconv) (rnrs bytevectors)) (define chaussette (socket PF_INET SOCK_STREAM 0)) (bind chaussette AF_INET INADDR_ANY 8081) (listen chaussette 1) (display "Chaussette en place") (newline) (while #t (let (( rep (accept chaussette ))) (let ((out (car rep)) (in (cdr rep))) (define text (make-bytevector 1024)) (define pos #f) (recvfrom! out text) (set! pos (string-contains (bytevector->string text "UTF-8") (string #\return #\nl))) ;; si ya pas de \cr\nl, buffer trop grand ou mal formaté (if (not pos) (display (string-append "59 Bad Request" (string #\return #\nl)) out) (display "all ok") ) (shutdown out 2) ))) (close chaussette) (display "Atterissage réussi") (newline)