Mercurial > repos > tabletprog
annotate samples/http.tp @ 216:2dac67e9d18b
Add -m flag to compiler driver to select macro expansion only
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 21 Dec 2013 12:07:00 -0800 |
parents | 55e0dca7d3d7 |
children |
rev | line source |
---|---|
149
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #{ |
153
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
2 main <- :args { |
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
3 server <- "rhope.retrodev.com" |
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
4 if: (args length) > 1 { |
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
5 server <- args get: 1 |
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
6 } |
075b1e71feff
A little more work on the HTTP module
Mike Pavone <pavone@retrodev.com>
parents:
149
diff
changeset
|
7 cli <- http client: server |
157
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
8 resp <- (cli get: "/") |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
9 print: "Status: " . (resp status) . "\n" |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
10 print: "Code: " . (resp statusCode) . "\n" |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
11 print: "Headers:\n" |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
12 foreach: (resp headers) :key val { |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
13 print: key . " -> " . val . "\n" |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
14 } |
55e0dca7d3d7
Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents:
153
diff
changeset
|
15 print: "Body:\n" . (resp body) . "\n" |
149
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 } |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 } |