From 103cb2bfa6fac5e145b198956403faf85e902997 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 15 Oct 2013 09:58:00 -0600 Subject: [PATCH] Restoring old decoding behavior of net/url and allowing future compatibility by parameterizing what is accepted original commit: 0a336024a9d1a9c84386f23c1fdc5684143c43de --- .../racket-doc/net/scribblings/http-client.scrbl | 13 +++++++++++-- .../racket-doc/net/scribblings/url.scrbl | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/racket-pkgs/racket-doc/net/scribblings/http-client.scrbl b/pkgs/racket-pkgs/racket-doc/net/scribblings/http-client.scrbl index 6eaafd2d73..533042c685 100644 --- a/pkgs/racket-pkgs/racket-doc/net/scribblings/http-client.scrbl +++ b/pkgs/racket-pkgs/racket-doc/net/scribblings/http-client.scrbl @@ -72,6 +72,7 @@ Closes the output side of @racket[hc], if it is live. [#:version version (or/c bytes? string?) #"1.1"] [#:method method (or/c bytes? string? symbol?) #"GET"] [#:headers headers (listof (or/c bytes? string?)) empty] + [#:content-decode decodes (listof symbol?) '(gzip)] [#:data data (or/c false/c bytes? string?) #f]) void?]{ @@ -80,16 +81,22 @@ HTTP version @racket[version] the method @racket[method] and the additional headers given in @racket[headers] and the additional data @racket[data]. +If @racket[headers] does not contain an @litchar{Accept-Encoding} +header, then a header indicating that encodings from @racket[decodes] +are accepted is automatically added. + This function does not support requests that expect @litchar{100 (Continue)} responses. } @defproc[(http-conn-recv! [hc http-conn-live?] + [#:content-decode decodes (listof symbol?) '(gzip)] [#:close? close? boolean? #f]) (values bytes? (listof bytes?) input-port?)]{ -Parses an HTTP response from @racket[hc]. +Parses an HTTP response from @racket[hc], while decoding the encodings +listed in @racket[decodes]. Returns the status line, a list of headers, and an port which contains the contents of the response. @@ -106,6 +113,7 @@ to do so. [#:method method (or/c bytes? string? symbol?) #"GET"] [#:headers headers (listof (or/c bytes? string?)) empty] [#:data data (or/c false/c bytes? string?) #f] + [#:content-decode decodes (listof symbol?) '(gzip)] [#:close? close? boolean? #f]) (values bytes? (listof bytes?) input-port?)]{ @@ -119,7 +127,8 @@ Calls @racket[http-conn-send!] and @racket[http-conn-recv!] in sequence. [#:version version (or/c bytes? string?) #"1.1"] [#:method method (or/c bytes? string? symbol?) #"GET"] [#:headers headers (listof (or/c bytes? string?)) empty] - [#:data data (or/c false/c bytes? string?) #f]) + [#:data data (or/c false/c bytes? string?) #f] + [#:content-decode decodes (listof symbol?) '(gzip)]) (values bytes? (listof bytes?) input-port?)]{ Calls @racket[http-conn-send!] and @racket[http-conn-recv!] in diff --git a/pkgs/racket-pkgs/racket-doc/net/scribblings/url.scrbl b/pkgs/racket-pkgs/racket-doc/net/scribblings/url.scrbl index f6346d4b83..0a9749d8c7 100644 --- a/pkgs/racket-pkgs/racket-doc/net/scribblings/url.scrbl +++ b/pkgs/racket-pkgs/racket-doc/net/scribblings/url.scrbl @@ -433,7 +433,8 @@ mapping is the empty list (i.e., no proxies).} @defproc[(http-sendrecv/url [u url?] [#:method method (or/c bytes? string? symbol?) #"GET"] [#:headers headers (listof (or/c bytes? string?)) empty] - [#:data data (or/c false/c bytes? string?) #f]) + [#:data data (or/c false/c bytes? string?) #f] + [#:content-decode decodes (listof symbol?) '(gzip)]) (values bytes? (listof bytes?) input-port?)]{ Calls @racket[http-sendrecv] using @racket[u] to populate the host, URI, port, and SSL parameters.