+(define (redirect-permanent new-uri)
+ (print "30 " (uri->string new-uri) "\r"))
+
+(define (serve-query prompt)
+ (print "10 " prompt "\r"))
+
+(define (uri-lacks-trailing-slash? uri)
+ (not (string-null? (last (uri-path uri)))))
+
+(define (uri-with-trailing-slash uri)
+ (update-uri uri path: (append (uri-path uri) '(""))))
+
+(define (valid-hostname name)
+ (let*
+ ((host-label-part '(+ (or alphanumeric #\- #\_)))
+ (domain-part `(: #\. ,host-label-part))
+ (hostname-regex `(: ,host-label-part (+ ,domain-part))))
+ (irregex-match? hostname-regex name)))
+
+(define (existing-host config uri)
+ (directory-exists? (make-pathname (config-root-dir config) (uri-host uri))))
+