view samples/http.tp @ 251:2557ce4e671f

Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
author Michael Pavone <pavone@retrodev.com>
date Fri, 11 Apr 2014 22:29:32 -0700
parents 55e0dca7d3d7
children
line wrap: on
line source

#{
	main <- :args {
		server <- "rhope.retrodev.com"
		if: (args length) > 1 {
			server <- args get: 1
		}
		cli <- http client: server
		resp <- (cli get: "/")
		print: "Status: " . (resp status) . "\n"
		print: "Code: " . (resp statusCode) . "\n"
		print: "Headers:\n"
		foreach: (resp headers) :key val {
			print: key . " -> " . val . "\n"
		}
		print: "Body:\n" . (resp body) . "\n"
	}
}