(mime-type (cadr mime)))
(print "20 " (string-intersperse (cdr mime) ";") "\r")
(cond
- ((equal? mime-type "text/gemini") (serve-dynamic-gemini path))
- ((equal? mime-type "text/plain") (serve-text-plain path))
- (else (serve-binary)))))
+ ((and (equal? mime-type "text/gemini")
+ (file-executable? path))
+ (serve-text-dynamic path))
+ ((string-prefix? "text/" mime-type)
+ (serve-text-plain path))
+ (else (serve-binary path)))))
(define (serve-text-plain path)
(with-input-from-file path
(print* str)
(loop (read-string)))))))
-(define (serve-dynamic-gemini path)
+(define (serve-text-dynamic path)
(with-input-from-file path
(lambda ()
(let loop ((c (peek-char)))
(change-directory old-wd)
(signal o)))))
-
(define (run-server config)
(define listener (ssl-listen* hostname: (config-host config)
port: (config-port config)
(print "One or more invalid arguments.")
(print-usage progname)))))))))
-
(main)