Skip to content

Instantly share code, notes, and snippets.

@emk
Created April 6, 2009 19:18
Show Gist options
  • Save emk/90885 to your computer and use it in GitHub Desktop.
Save emk/90885 to your computer and use it in GitHub Desktop.
;; Insert somewhere in test/scripts/features.ss to test.
(card /features/http (%standard-test-card% :title "HTTP")
(edit-box result
((inset-rect $screen-rect 50)
""
:multiline? #t
:font-size 12))
(run
(with-values [[tcp-in tcp-out]
(tcp-connect "iml.dartmouth.edu" 80)]
(fprintf tcp-out "GET /halyard/ HTTP/1.1\r\nHost: iml.dartmouth.edu\r\n\r\n")
(close-output-port tcp-out)
(let loop [[line (read-line tcp-in 'return-linefeed)]]
(unless (eof-object? line)
(set! (.result.text) (string-append (.result.text) line "\n"))
(loop (read-line tcp-in 'return-linefeed)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment