implement Hget; include "sys.m"; sys: Sys; include "draw.m"; Context: import Draw; include "arg.m"; arg : Arg; include "sslsession.m"; include "keyring.m"; include "asn1.m"; include "pkcs.m"; include "x509.m"; include "ssl3.m"; ssl3: SSL3; include "httpc.m"; httpc :Httpc; Connection, Response, Request : import httpc; Hget : module { init: fn(nil: ref Context, args : list of string); }; crack_uri(u : string) : (string, string, string) { return("tcp!192.168.9.14!80", "bang", "/"); } init(nil: ref Context, args: list of string) { proxy := ""; host := ""; sys = load Sys Sys->PATH; arg = load Arg Arg->PATH; arg->init(args); arg->setusage("hget [-p proxy] [-h host] uri"); while((c := arg->opt()) != 0) case c { 'f' => proxy = arg->earg(); 'h' => host = arg->earg(); } if(len args != 2) arg->usage(); httpc = load Httpc Httpc->PATH; httpc->init(); (dialstring, dom, uri) := crack_uri(hd args); method := "GET"; if(host == "") host = dom; h := httpc->new_connection(dialstring); r := h.send_request(ref Request(host, method, uri, "1.1", "Inferno: Maht's hget", nil, nil)); sys->print("%s\n", r.body_string()); } # hget ate