From 77c61e5eafd82d6ada7ab94986d045ec49f398b1 Mon Sep 17 00:00:00 2001 From: Kat Lyons Date: Thu, 14 Aug 2014 21:34:15 -0600 Subject: [PATCH] Add net/http-client to Typed Racket original commit: 7ed93e6fba55e4c3360e9a3fae5be9cc871d9aef --- .../scribblings/reference/libraries.scrbl | 1 + .../typed/net/http-client.rkt | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 pkgs/typed-racket-pkgs/typed-racket-more/typed/net/http-client.rkt diff --git a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl index 60881d89..7a08d3f9 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl +++ b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/reference/libraries.scrbl @@ -57,6 +57,7 @@ The following libraries are included with Typed Racket in the @defmodule/incl[typed/net/ftp] @defmodule/incl[typed/net/gifwrite] @defmodule/incl[typed/net/head] +@defmodule/incl[typed/net/http-client] @defmodule/incl[typed/net/imap] @defmodule/incl[typed/net/mime] @defmodule/incl[typed/net/nntp] diff --git a/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/http-client.rkt b/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/http-client.rkt new file mode 100644 index 00000000..a5cc778e --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-more/typed/net/http-client.rkt @@ -0,0 +1,48 @@ +#lang typed/racket/base + +(define-type BString (U Bytes String)) + +(require (only-in typed/openssl + SSL-Client-Context)) + +(require/typed/provide net/http-client + [#:opaque HTTP-Connection http-conn?] + [http-conn (-> HTTP-Connection)] + [http-conn-live? (-> HTTP-Connection Boolean)] + + [http-conn-open! + (->* [HTTP-Connection BString] + [#:ssl? (U Boolean Symbol SSL-Client-Context) #:port Positive-Integer] + Void)] + + [http-conn-open + (->* [BString] + [#:ssl? (U Boolean Symbol SSL-Client-Context) #:port Positive-Integer] + HTTP-Connection)] + + [http-conn-close! (-> HTTP-Connection Void)] + [http-conn-abandon! (-> HTTP-Connection Void)] + + [http-conn-send! + (->* [HTTP-Connection BString] + [#:version BString #:method (U BString Symbol) #:close? Boolean #:headers (Listof BString) + #:content-decode (Listof Symbol) #:data (Option BString)] + Void)] + + [http-conn-recv! + (->* [HTTP-Connection] + [#:content-decode (Listof Symbol) #:close? Boolean] + (values Bytes (Listof Bytes) Input-Port))] + + [http-conn-sendrecv! + (->* [HTTP-Connection BString] + [#:version BString #:method (U BString Symbol) #:headers (Listof BString) + #:data (Option BString) #:content-decode (Listof Symbol) #:close? Boolean] + (values Bytes (Listof Bytes) Input-Port))] + + [http-sendrecv + (->* [BString BString] + [#:ssl? (U Boolean Symbol SSL-Client-Context) #:port Positive-Integer #:version BString + #:method (U BString Symbol) #:headers (Listof BString) #:data (Option BString) + #:content-decode (Listof Symbol)] + (values Bytes (Listof Bytes) Input-Port))])