Last active
August 29, 2015 14:26
-
-
Save utgwkk/4106b179f8084e5b4074 to your computer and use it in GitHub Desktop.
Show the content of the given host and URL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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