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
|
|
|
|
|
2002-11-29 09:49:22 -05:00
|
|
|
(define-record-type request :request
|
|
|
|
(make-request method uri url version headers socket)
|
|
|
|
request?
|
|
|
|
(method request-method) ; A string such as "GET", "PUT", etc.
|
|
|
|
(uri request-uri) ; The escaped URI string as read from request line.
|
|
|
|
(url request-url) ; An http URL record (see url.scm).
|
|
|
|
(version request-version) ; A (major . minor) integer pair.
|
|
|
|
(headers request-headers) ; An rfc822 header alist (see rfc822.scm).
|
|
|
|
(socket request-socket)) ; The socket connected to the client.
|
|
|
|
|
|
|
|
(define-record-discloser :request
|
2002-05-26 13:56:56 -04:00
|
|
|
(lambda (req)
|
|
|
|
(list 'request
|
2002-11-29 09:49:22 -05:00
|
|
|
(request-method req)
|
|
|
|
(request-uri req)
|
|
|
|
(request-url req)
|
|
|
|
(request-version req)
|
|
|
|
(request-headers req)
|
|
|
|
(request-socket req))))
|
2002-05-26 13:56:56 -04:00
|
|
|
;;; 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)
|
2002-11-29 09:49:22 -05:00
|
|
|
(version<= (request-version req) '(0 . 9)))
|
2002-05-26 13:56:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
(define (version->string v)
|
|
|
|
(string-append "HTTP/"
|
|
|
|
(number->string (car v))
|
|
|
|
"."
|
|
|
|
(number->string (cdr v))))
|
|
|
|
|