[racket] retrieving an https url

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sat Jun 18 16:30:36 EDT 2011

I've put all of these examples up on the GitHub Racket wiki:
  https://github.com/plt/racket/wiki/HTTP-over-SSL

Hopefully, that will be a useful reference the next time someone asks about SSL.

On Sat, Jun 18, 2011 at 11:39 AM, YC <yinso.chen at gmail.com> wrote:
> You can also try bzlib/http on planet - it can work with SSL via the
> following call:
>
> (require (planet bzlib/http/client))
>
> (http-get <url> <list-of-headers>)
>
> (http-post <url> <data> <list-of-headers>)
>
> Hope this helps.
> yc
> On Sat, Jun 18, 2011 at 8:05 AM, Matthias Felleisen <matthias at ccs.neu.edu>
> wrote:
>>
>> I have modernized the language (not really necessary) and adapted
>> the example so that it does something useful (not very) with a real https
>> url. See below. It's all in one drracket buffer to make it more
>> easily readable. I am sure you can split it up into separate files.
>>
>> Basically all exports documented at
>>
>>  http://docs.racket-lang.org/net/url.html?q=url#(def._((lib._net/url-structs..rkt)._url))
>> are available prefixed with ssl: and you can contact web sites via post
>> and other
>> methods as explained there.
>>
>> hth -- Matthias
>>
>>
>>
>>
>> #lang racket/load
>>
>> (module ssl-url.ss racket
>>
>>  ;; From Eli Barzilay
>>
>>  ;; This will give us ssl:--- for an ssl version of url.ss, but still need
>> an
>>  ;; explicit port number specification since url.ss does not handle that
>>  (require racket/unit
>>           net/url-sig net/url-unit
>>           net/tcp-sig net/tcp-unit
>>           net/ssl-tcp-unit)
>>
>>  (define-values/invoke-unit (compound-unit/infer (import) (export url^)
>> (link tcp@ url@))
>>    (import)
>>    (export url^))
>>
>>  (define ssl-tcp@ (make-ssl-tcp@ #f #f #f #f #f #f #f))
>>
>>  (define-values/invoke-unit
>>    (compound-unit (import) (export URL)
>>                   (link [((TCP : tcp^)) ssl-tcp@]
>>                         [((URL : url^)) url@ TCP]))
>>    (import)
>>    (export (prefix ssl: url^)))
>>
>>  (provide (all-defined-out))
>>  )
>>
>> (module sample-client racket/gui
>>
>>  ; (require "ssl-url.ss")
>>  (require 'ssl-url.ss)
>>
>>  (define LOGIN "https://myneu.neu.edu/myneu/login/lock.gif")
>>
>>  (ssl:call/input-url
>>   (string->url LOGIN)
>>   ssl:get-pure-port
>>   (lambda (ip)
>>     (define file "login-image.gif")
>>     (with-output-to-file file (lambda () (copy-port ip
>> (current-output-port))) #:exists 'replace)
>>     (make-object image-snip% file 'gif))))
>>
>> (require 'sample-client)
>>
>>
>>
>>
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
sam th
samth at ccs.neu.edu



Posted on the users mailing list.