Changeset 11710 in project


Ignore:
Timestamp:
08/22/08 22:53:30 (12 years ago)
Author:
sjamaan
Message:

Add a few make-headers tests

Location:
release/4/intarweb/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/intarweb/trunk/header-parsers.scm

    r11709 r11710  
    313313                 (string-join result ","))
    314314        (let* ((contents (value+params-value (car headers)))
    315                (value (if (pair? contents)
     315               (value (if (pair? contents) ; alist?
    316316                          (conc (car contents) "=" (cdr contents))
    317317                          (->string contents)))
     
    324324                                 parameter-unparsers))
    325325                result))))))
    326 
  • release/4/intarweb/trunk/intarweb.scm

    r11709 r11710  
    110110(include "../header-parsers")
    111111
    112 ;; This includes parsers for all RFC-defined headers
     112;; Any unknown headers are considered to be multi-headers, always
    113113(define single-headers
    114114  (make-parameter '(accept-ranges age authorization content-length
     
    119119                    user-agent www-authenticate)))
    120120
     121;; This includes parsers for all RFC-defined headers
    121122(define header-parsers
    122123  (make-parameter
  • release/4/intarweb/trunk/tests/run.scm

    r11709 r11710  
    296296             (get-param '$version (second (get-header-contents 'cookie headers))))))))
    297297
     298(test-group "Make-headers"
     299  (test "Simple test"
     300        `(bar qux)
     301        (get-values
     302         (get-header-contents 'foo (make-headers `((foo bar qux))))))
     303  (test "Multi headers are folded"
     304        `(bar qux)
     305        (get-values
     306         (get-header-contents 'foo (make-headers `((foo bar)
     307                                                   (foo qux))))))
     308  (test "Single headers are unique"
     309        `(qux)
     310        (get-values
     311         (get-header-contents 'foo (parameterize ((single-headers '(foo)))
     312                                     (make-headers `((foo bar)
     313                                                     (foo qux)))))))
     314  (test "Extra single headers are ignored"
     315        `(qux)
     316        (get-values
     317         (get-header-contents 'foo (parameterize ((single-headers '(foo)))
     318                                     (make-headers `((foo bar qux)))))))
     319  (test "Parameters"
     320        `((bar . qux))
     321        (value+params-params
     322         (car (get-header-contents 'foo (make-headers `((foo #(mooh ((bar . qux))))))))))
     323  (test "Multi headers are folded into old headers"
     324        `(bar qux)
     325        (get-values
     326         (get-header-contents 'foo (make-headers `((foo qux))
     327                                                 (make-headers `((foo bar))))))))
     328
    298329;; TODO:
    299330;; - Implement comments parsing (better: a sane parsing system!)
Note: See TracChangeset for help on using the changeset viewer.