Method: (READ-REQUEST HTTPD-BACKEND T)

Documentation

Reads an HTTP request message from STREAM. Returns a httpd-request object.

Source

(defmethod read-request ((backend httpd-backend) stream)
  "Reads an HTTP request message from STREAM. Returns a httpd-request object."
  (let ((request (make-instance 'httpd-request :network-stream stream)))
    (destructuring-bind (http-method uri &optional protocol)
        (split-on-space (read-line-from-network backend stream))
      (declare (ignore protocol))
      (setf (http-method request) http-method
            (raw-uri request) (coerce uri 'simple-base-string)
            (query-path request) (aif (position #\? (raw-uri request))
                                      (make-displaced-array (raw-uri request) 0 it)
                                      (raw-uri request))
            (headers request) (read-request-headers backend stream))
      (awhen (get-header request "Content-Length")
        (let ((content-length (parse-integer it :junk-allowed t)))
          (when content-length
            ;; we really should inspect the encoding header to
            ;; decide the elment type of the body...
            (setf (raw-body request) (make-array content-length :element-type 'character))
            (read-sequence (raw-body request) stream)))))
    (parse-request-parameters request)
    request))
Source Context