[racket] retrieving an https url

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jun 18 11:05:41 EDT 2011

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 
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
  (define-values/invoke-unit (compound-unit/infer (import) (export url^) (link [email protected] [email protected])) 
    (export url^))
  (define [email protected] ([email protected] #f #f #f #f #f #f #f))
    (compound-unit (import) (export URL)
                   (link [((TCP : tcp^)) [email protected]]
                         [((URL : url^)) [email protected] TCP]))
    (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")
   (string->url LOGIN)
   (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)

On Jun 17, 2011, at 11:17 PM, Jordan Schatz wrote:

> I am still pretty new to Racket, I've built a few trivial projects and am
> now jumping into a more serious app. One of the first things I need to be
> able to do though is work with (as a client, not server) https urls. GET
> PUT POST HEAD DELETE, and most of the time send special headers.
> I have seen these:
> http://docs.racket-lang.org/openssl/index.html?q=ssl
> http://docs.racket-lang.org/net/url.html?q=put&q=ssl#(def._((lib._net/url..rkt)._get-pure-port))
> http://schemecookbook.org/view/Cookbook/WebFetchingHttpsUrl
> I think those are all the pieces I need but I don't really understand
> racket's unit system, and that last link appears abit dated. 
> Is the technique mentioned in WebFetchingHttpsUrl still the right way to
> do things? Do I need to update this to #lang racket? is there a
> better/more proper way?
> Thanks much!
> Jordan
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.