Changeset 11914 in project


Ignore:
Timestamp:
09/06/08 23:46:11 (12 years ago)
Author:
sjamaan
Message:

Implement improvement for entity-tag parser which makes it distinguish between quoted strong headers starting with 'W/' as value and regular weak headers

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

Legend:

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

    r11913 r11914  
    203203
    204204;; (W/)<string>
    205 (define (entity-tag-parser contents)
    206   (if (string-prefix? "W/" contents)
    207       `(weak . ,(string-drop contents 2))
    208       `(strong . ,contents)))
     205(define (entity-tag-parser name contents headers)
     206  (let ((contents (string-trim-both contents)))
     207    (replace-header-contents!
     208     name
     209     (list (if (string-prefix? "W/" contents)
     210               (vector `(weak . ,(parse-token contents 2 (char-set))) '())
     211               (vector `(strong . ,(parse-token contents 0 (char-set))) '())))
     212     headers)))
    209213
    210214;;;; MAJOR TODOs
  • release/4/intarweb/trunk/intarweb.scm

    r11913 r11914  
    222222     (content-type . ,(single symbol-parser-ci))
    223223     (date . ,(single http-time-parser))
    224      (etag . ,(single entity-tag-parser))
     224     (etag . ,entity-tag-parser)
    225225     (expect . ,(single key/values))
    226226     (expires . ,(single rfc822-time-parser))
  • release/4/intarweb/trunk/tests/run.scm

    r11910 r11914  
    187187            '(strong . "")
    188188            (get-value (car (header-contents 'etag headers)))))
    189     ;; XXX, is this test important to pass?
    190     #;(let ((headers (test-read-headers "Etag: \"W/bar\"")))
     189    (let ((headers (test-read-headers "Etag: \"W/bar\"")))
    191190        (test "Strong tag, containing W/ prefix"
    192               '(strong . "W/foo")
     191              '(strong . "W/bar")
    193192              (get-value (car (header-contents 'etag headers))))))
    194193
     
    559558;; - Use SRFI-19
    560559;; - Rethink the auto-chunking stuff. Maybe this should be done at a higher level
     560;; - Think about a good naming convention to distinguish parsers that accept
     561;;    one argument (an already-tokenized string) or multiple (raw header data)
Note: See TracChangeset for help on using the changeset viewer.