Changeset 13478 in project


Ignore:
Timestamp:
03/03/09 23:17:53 (11 years ago)
Author:
sjamaan
Message:

Add keep-alive? predicate for request and response objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/intarweb/trunk/intarweb.scm

    r13053 r13478  
    4242   headers? headers->list http-name->symbol symbol->http-name
    4343   header-parsers header-unparsers unparse-header unparse-headers
     44   keep-alive?
    4445   
    4546   make-request request? request-major request-major-set!
     
    210211                           (peek-char port)
    211212                           #!eof)))))
     213
     214(define (keep-alive? obj)
     215  (let ((major (if (request? obj) (request-major obj) (response-major obj)))
     216        (minor (if (request? obj) (request-minor obj) (response-minor obj)))
     217        (con   (header-value 'connection (if (request? obj)
     218                                             (request-headers obj)
     219                                             (response-headers obj)))))
     220   (if (and (= major 1) (> minor 0))
     221       (not (eq? con 'close))
     222       ;; RFC 2068, section 19.7.1 (see also RFC 2616, section 19.6.2)
     223       (eq? con 'keep-alive))))
    212224
    213225;;;;;;;;;;;;;;;;;;;;;;;;;
Note: See TracChangeset for help on using the changeset viewer.