NullLogic

This is a _very_ basic HTTP client.

#!/usr/bin/nsp function test(host, port, uri, ssl) { try { dl.load("net"); c=new net.socket(); c.connect(host, port, ssl); if (c.gettype()!='sock4') { throw sprintf("can't connect to server '%s'", host); } c.write("GET "+uri+" HTTP 1.0\r\n"); c.write("Host: "+host+"\r\n"); c.write("Connection: close\r\n"); c.write("\r\n"); headers={}; body=""; while (true) { x=c.gets(); if (x==null || x=="") break; headers[headers.length()]=x; } while (true) { x=c.read(); if (x==null || x=="") break; body+=x; } c.close(); foreach (line in headers) { printf("[%s]\r\n", line); } printf("\r\n%s", body); } catch (ex) { printf("\r\nException: %s", ex.description); } } test("nulllogic.ca", 80, "/nsp/version.php", false); //test("nulllogic.ca", 443, "/nsp/version.php", true);