diff --git a/collects/unstable/bytes.rkt b/collects/unstable/bytes.rkt index daf1e39e92..ecb1264d57 100644 --- a/collects/unstable/bytes.rkt +++ b/collects/unstable/bytes.rkt @@ -1,19 +1,9 @@ #lang racket/base -(require racket/contract/base - racket/serialize) +(require racket/contract/base) (provide/contract - [read/bytes (bytes? . -> . serializable?)] - [write/bytes (serializable? . -> . bytes?)] - [bytes-ci=? (bytes? bytes? . -> . boolean?)]) - -(define (bytes-ci=? b0 b1) - (string-ci=? (bytes->string/utf-8 b0) - (bytes->string/utf-8 b1))) -;; Eli: If this ever gets in, it should say that the memory requirements -;; are 4 times the input size, especially since bytes are often used to save -;; space. Also, fails on (bytes-ci=? #"\277" #"\277"), and a trivial fix -;; would still fail on (bytes-ci=? #"\276\277" #"\277\276") + [read/bytes (bytes? . -> . printable/c)] + [write/bytes (printable/c . -> . bytes?)]) (define (read/bytes bs) (read (open-input-bytes bs))) diff --git a/collects/unstable/scribblings/bytes.scrbl b/collects/unstable/scribblings/bytes.scrbl index 40616456d6..e0ef8321c5 100644 --- a/collects/unstable/scribblings/bytes.scrbl +++ b/collects/unstable/scribblings/bytes.scrbl @@ -1,6 +1,6 @@ #lang scribble/doc @(require scribble/base scribble/manual "utils.rkt" - (for-label racket/base unstable/bytes racket/serialize + (for-label racket/base unstable/bytes racket/contract)) @title[#:tag "bytes"]{Bytes} @@ -9,16 +9,12 @@ @unstable-header[] -@defproc[(bytes-ci=? [b1 bytes?] [b2 bytes?]) boolean?]{ - Compares two bytes case insensitively. -} - @defproc[(read/bytes [b bytes?]) - serializable?]{ + printable/c]{ @racket[read]s a value from @racket[b] and returns it. } -@defproc[(write/bytes [v serializable?]) +@defproc[(write/bytes [v printable/c]) bytes?]{ @racket[write]s @racket[v] to a bytes and returns it. } diff --git a/collects/web-server/private/util.rkt b/collects/web-server/private/util.rkt index 6e8ac6b199..1d563653ae 100644 --- a/collects/web-server/private/util.rkt +++ b/collects/web-server/private/util.rkt @@ -16,6 +16,19 @@ ;; -- +(define (bytes-ci=? b0 b1) + (string-ci=? (bytes->string/utf-8 b0) + (bytes->string/utf-8 b1))) +;; Eli: If this ever gets in, it should say that the memory requirements +;; are 4 times the input size, especially since bytes are often used to save +;; space. Also, fails on (bytes-ci=? #"\277" #"\277"), and a trivial fix +;; would still fail on (bytes-ci=? #"\276\277" #"\277\276") + +(provide/contract + [bytes-ci=? (bytes? bytes? . -> . boolean?)]) + +;; -- + ;; network-error: symbol string . values -> void ;; throws a formatted exn:fail:network (define (network-error src fmt . args)