58 lines
1.6 KiB
Common Lisp
58 lines
1.6 KiB
Common Lisp
;;;; CLASH --- The Common Lisp Adaptable Simple HTTP server
|
|
;;;; This is copyrighted software. See documentation for terms.
|
|
;;;;
|
|
;;;; http-io.cl --- HTTP conforming input and output routines and codecs
|
|
;;;;
|
|
;;;; Checkout Tag: $Name$
|
|
;;;; $Id$
|
|
|
|
(in-package :CLASH)
|
|
|
|
;;;; %File Description:
|
|
;;;;
|
|
;;;;
|
|
;;;;
|
|
|
|
(defun read-http-line (stream)
|
|
(declare (optimize (speed 3) (safety 0) (debug 0))
|
|
(type stream stream))
|
|
(let ((string (make-array 80 :element-type 'character :fill-pointer 0
|
|
:adjustable t)))
|
|
(declare (type string string))
|
|
(do ((char (read-char stream) (read-char stream)))
|
|
((char= char #\Newline) (coerce string 'simple-string))
|
|
(declare (type character char))
|
|
(unless (char= char #\Return)
|
|
(vector-push-extend char string)))))
|
|
|
|
#+NIL
|
|
(defun read-http-line (stream)
|
|
(declare (optimize (speed 3) (safety 0) (debug 0))
|
|
(type stream stream))
|
|
(with-output-to-string (out)
|
|
(do ((char (read-char stream) (read-char stream)))
|
|
((char= char #\Newline))
|
|
(declare (character char))
|
|
(unless (char= char #\Return)
|
|
(write-char char out)))))
|
|
|
|
#+NIL
|
|
(defun read-http-line (stream)
|
|
(let ((in-line (read-line stream nil nil)))
|
|
(if in-line
|
|
(string-right-trim '(#\Return) in-line)
|
|
in-line)))
|
|
|
|
(declaim (inline http-terpri))
|
|
(defun http-terpri (stream)
|
|
(write-char #\Return stream)
|
|
(write-char #\Newline stream))
|
|
|
|
(defun write-http-line (string stream)
|
|
(write-string string stream)
|
|
(http-terpri stream))
|
|
|
|
(declaim (inline write-http-element-list-1))
|
|
(defun write-http-element-list-1 (list stream)
|
|
(format stream "~{~A~^, ~:}" list))
|