mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
36 lines
699 B
Scheme
Executable file
36 lines
699 B
Scheme
Executable file
#! /usr/bin/env chibi-scheme
|
|
|
|
; Simple HTTP client
|
|
; Retrieves the contents of the URL argument:
|
|
|
|
; Usage:
|
|
; simple-http-client.scm [URL]
|
|
;
|
|
; Example:
|
|
; simple-http-client.scm http://localhost:8000
|
|
|
|
(import (chibi) (chibi net) (chibi net http) (chibi io))
|
|
|
|
(if (> (length (command-line)) 1)
|
|
(let ((url (car (cdr (command-line)))))
|
|
(if (> (string-length url) 0)
|
|
(begin
|
|
(display (read-string 65536 (http-get url)))
|
|
(newline))))
|
|
(let ((progname (car (command-line))))
|
|
(display "Retrieve the contents of a URL.")
|
|
(newline)
|
|
(display "Usage:")
|
|
(newline)
|
|
(newline)
|
|
(display progname)
|
|
(display " [URL]")
|
|
(newline)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|