2002-05-26 13:56:56 -04:00
|
|
|
;;;; HTTP request
|
2002-08-27 05:03:22 -04:00
|
|
|
|
|
|
|
;;; This file is part of the Scheme Untergrund Networking package.
|
|
|
|
;;; Copyright (c) 1996 by Olin Shivers.
|
|
|
|
;;; For copyright information, see the file COPYING which comes with
|
|
|
|
;;; the distribution.
|
|
|
|
|
2002-05-26 13:56:56 -04:00
|
|
|
;;;; This code defines the http REQUEST data structure
|
|
|
|
|
|
|
|
(define-record request
|
|
|
|
method ; A string such as "GET", "PUT", etc.
|
|
|
|
uri ; The escaped URI string as read from request line.
|
|
|
|
url ; An http URL record (see url.scm).
|
|
|
|
version ; A (major . minor) integer pair.
|
|
|
|
headers ; An rfc822 header alist (see rfc822.scm).
|
|
|
|
socket) ; The socket connected to the client.
|
|
|
|
|
|
|
|
(define-record-discloser type/request
|
|
|
|
(lambda (req)
|
|
|
|
(list 'request
|
|
|
|
(request:method req)
|
|
|
|
(request:uri req)
|
|
|
|
(request:url req)
|
|
|
|
(request:version req)
|
|
|
|
(request:headers req)
|
|
|
|
(request:socket req))))
|
|
|
|
;;; A http protocol version is an integer pair: (major . minor).
|
|
|
|
|
|
|
|
(define (version< v1 v2)
|
|
|
|
(or (< (car v1) (car v2))
|
|
|
|
(and (= (car v1) (car v2))
|
|
|
|
(< (cdr v1) (cdr v2)))))
|
|
|
|
|
|
|
|
(define (version<= v1 v2) (not (version< v2 v1)))
|
|
|
|
|
|
|
|
(define (v0.9-request? req)
|
|
|
|
(version<= (request:version req) '(0 . 9)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (version->string v)
|
|
|
|
(string-append "HTTP/"
|
|
|
|
(number->string (car v))
|
|
|
|
"."
|
|
|
|
(number->string (cdr v))))
|
|
|
|
|