Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Last active December 17, 2015 08:19
Show Gist options
  • Save grauwoelfchen/5579295 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/5579295 to your computer and use it in GitHub Desktop.
Hello Racket ;)
(require racket/tcp)
(let-values ([(inp outp) (tcp-connect "racket-lang.org" 80)])
(display "GET / HTTP/1.0\n\n" outp)
(close-output-port outp)
(let ([o (open-output-string)])
(let aux ([r (read inp)])
(if (eof-object? r)
(display (get-output-string o))
(begin (display r o)
(aux (read inp))))))
(close-input-port inp))
HTTP/1.1302FoundDate:Tue(unquote 14)May201320:29:17GMTServer:Apache/2.2.15(Fedora)Location:http://racket-lang.org/Vary:Accept-EncodingContent-Length:294Connection:closeContent-Type:text/html<!DOCTYPEHTMLPUBLIC-//IETF//DTD HTML 2.0//EN><html><head><title>302Found</title></head><body><h1>Found</h1><p>Thedocumenthasmoved<ahref=http://racket-lang.org/>here</a>.</p><hr><address>Apache/2.2.15(Fedora)Serveratchamplain.ccs.neu.eduPort80</address></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment