Changeset 13594 in project


Ignore:
Timestamp:
03/08/09 15:30:32 (11 years ago)
Author:
sjamaan
Message:

Add remove-header procedures

File:
1 edited

Legend:

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

    r13478 r13594  
    22;; Intarweb is an improved HTTP library for Chicken
    33;;
    4 ; Copyright (c) 2008, Peter Bex
     4; Copyright (c) 2008-2009, Peter Bex
    55; All rights reserved.
    66;
     
    3939(module intarweb
    4040  (read-line-limit replace-header-contents replace-header-contents!
     41   remove-header remove-header!
    4142   update-header-contents update-header-contents! headers single-headers
    4243   headers? headers->list http-name->symbol symbol->http-name
     
    9596(define headers->list headers-v)
    9697
     98(define (remove-header! name headers)
     99  (let loop ((h (headers-v headers)))
     100    (cond
     101     ((null? h) headers)
     102     ((eq? name (caar h))
     103      (set-cdr! h (cdr h))
     104      headers)
     105     (else (loop (cdr h))))))
     106
     107(define (remove-header name headers)
     108  (make-headers
     109   (let loop ((h (headers-v headers)))
     110     (cond
     111      ((null? h) h)
     112      ((eq? name (caar h)) (loop (cdr h)))
     113      (else (cons (car h) (loop (cdr h))))))))
     114
    97115;; XXX: Do we need these replace procedures in the exports list?  It
    98 ;; looks like we can use update everywhere.  A remove-header could
    99 ;; be useful, though.
     116;; looks like we can use update everywhere.
    100117(define (replace-header-contents! name contents headers)
    101118  (let loop ((h (headers-v headers)))
Note: See TracChangeset for help on using the changeset viewer.