Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/4106b179f8084e5b4074 to your computer and use it in GitHub Desktop.
Save utgwkk/4106b179f8084e5b4074 to your computer and use it in GitHub Desktop.
Show the content of the given host and URL.
; refer the nth element of list)
(define (list-ref lst n)
(cond
((null? lst) "Out of range")
((= 0 n) (car lst))
(else (list-ref (cdr lst) (- n 1)))
)
)
; Read string from input-port
(define (read-port p)
(let loop((ls1 '()) (c (read-char p)))
(if
(eof-object? c)(list->string (reverse ls1))
(loop (cons c ls1) (read-char p))
)
)
)
; This code shows the body of http://utgw.net/.
(require net/http-client)
(define host "utgw.net")
(define iport
(list-ref (call-with-values (lambda () (http-sendrecv host "/")) list) 2)
)
(display (read-port iport))
(close-input-port iport)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment