From b93b0de22894753adf9d51cd0e9e922771e42021 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 31 Jan 2014 11:35:30 -0500 Subject: [PATCH] Update typed/net/url Closes PR 14330 original commit: f1adc8e856109b7740c191a9ab2a964643c569f7 --- .../typed-racket-more/typed/net/url.rkt | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/url.rkt b/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/url.rkt index f435cb0f..3053e875 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/url.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/url.rkt @@ -18,17 +18,24 @@ (require/opaque-type URL-Exception url-exception? net/url) (provide URL-Exception url-exception?) +(require/opaque-type HTTP-Connection http-connection? net/url) +(provide HTTP-Connection http-connection?) + (define-type-alias PortT (case-lambda (url -> Input-Port) (url (Listof String)-> Input-Port))) (define-type-alias PortT/String (case-lambda (url String -> Input-Port) (url String (Listof String)-> Input-Port))) +(define-type-alias PortT/Bytes (case-lambda (url Bytes -> Input-Port) (url Bytes (Listof String)-> Input-Port))) +(provide PortT PortT/String PortT/Bytes) (require/typed/provide net/url - [path->url (Path -> url)] + [path->url (Path-String -> url)] [url->path (case-lambda (url -> Path) (url (U 'unix 'windows) -> Path))] [file-url-path-convention-type (Parameter (U 'unix 'windows))] - [get-pure-port PortT] + [get-pure-port + (case-> (url [#:redirections Natural] -> Input-Port) + (url (Listof String) [#:redirections Natural] -> Input-Port))] [head-pure-port PortT] [delete-pure-port PortT] @@ -36,19 +43,40 @@ [head-impure-port PortT] [delete-impure-port PortT] - [post-pure-port PortT/String] - [put-pure-port PortT/String] + [post-pure-port PortT/Bytes] + [put-pure-port PortT/Bytes] - [post-impure-port PortT/String] - [put-impure-port PortT/String] + [post-impure-port PortT/Bytes] + [put-impure-port PortT/Bytes] [display-pure-port (Input-Port -> Void)] [purify-port (Input-Port -> String)] + [get-pure-port/headers + (case-> (url [#:redirections Natural] + [#:status? Boolean] + [#:connection (Option HTTP-Connection)] + -> (values Input-Port String)) + (url (Listof String) + [#:redirections Natural] + [#:status? Boolean] + [#:connection (Option HTTP-Connection)] + -> (values Input-Port String)))] + + [make-http-connection (-> HTTP-Connection)] + [http-connection-close (HTTP-Connection -> Void)] + [call/input-url (case-lambda [url url (Input-Port -> Any) -> Any])] ;;FIXME - need polymorphism [current-proxy-servers (Parameter (Listof (List String String Integer)))] + [http-sendrecv/url + (url [#:method (U Bytes String Symbol)] + [#:headers (Listof (U Bytes String))] + [#:data (Option (U Bytes String))] + [#:content-decode (Listof Symbol)] + -> (values Bytes (Listof Bytes) Input-Port))] + [netscape/string->url (String -> url)] [string->url (String -> url)] [url->string (url -> String)]