32 lines
666 B
Hare
32 lines
666 B
Hare
use fmt;
|
|
use io;
|
|
use net::dial;
|
|
use net::http;
|
|
use net::uri;
|
|
use os;
|
|
|
|
export fn main() void = {
|
|
const client = http::newclient("Hare test client");
|
|
defer http::client_finish(&client);
|
|
|
|
const target = match (uri::parse(os::args[1])) {
|
|
case let u: uri::uri =>
|
|
yield u;
|
|
case uri::invalid =>
|
|
fmt::fatal("Invalid URI");
|
|
};
|
|
defer uri::finish(&target);
|
|
|
|
const req = http::get(&client, &target);
|
|
const resp = match (http::do(&client, &req)) {
|
|
case let err: http::error =>
|
|
fmt::fatal("HTTP error:", http::strerror(err));
|
|
case let resp: http::response =>
|
|
yield resp;
|
|
};
|
|
|
|
// XXX TEMP
|
|
const body = resp.body as io::handle;
|
|
io::copy(os::stdout, body)!;
|
|
};
|