changeset 149:7f442b3e4448

Tiny bit of work on HTTP client and sample usage of it
author Mike Pavone <pavone@retrodev.com>
date Fri, 09 Aug 2013 05:28:35 -0700
parents 5071d601fe70
children 7dfa4481deb0
files modules/http.tp samples/http.tp
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/http.tp	Fri Aug 09 05:28:35 2013 -0700
@@ -0,0 +1,17 @@
+#{
+	client:usingPort <- :address :port{
+		#{
+			get <- :path {
+				sock <- socket connectTo: address onPort: port
+				sock send: "GET " . path . " HTTP/1.1\r\nHost: " . address . "\r\n\r\n"
+				resp <- sock recv 4096
+				print: resp
+				sock close
+			}
+		}
+	}
+
+	client <- :address {
+		client: address usingPort: 80
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/http.tp	Fri Aug 09 05:28:35 2013 -0700
@@ -0,0 +1,6 @@
+#{
+	main <- {
+		cli <- http client: "rhope.retrodev.com"
+		print: (string: (cli get: "/"))
+	}
+}