3 import { basename, stdout } from "fs";
4 let uloop = require("uloop");
5 let uclient = require("uclient");
7 function fetch_data() {
9 while (length(data = uc.read()) > 0)
13 let url = shift(ARGV);
15 warn(`Usage: ${basename(sourcepath())} <url>\n`);
20 uc = uclient.new(url, null, {
22 warn(sprintf("Headers: %.J\nStatus: %.J\n", uc.get_headers(), uc.status()));
24 data_read: fetch_data,
30 warn(`Error: ${code}\n`);
35 if (!uc.ssl_init({ verify: false })) {
36 warn(`Failed to initialize SSL\n`);
41 warn(`Failed to connect\n`);
45 if (!uc.request("GET")) {
46 warn(`Failed to send request\n`);