Mercurial > repos > tabletprog
annotate samples/http.tp @ 177:76e3d4ae1746
Support more bitwise operations and function pointers in llMessages
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 24 Aug 2013 09:54:47 -0700 |
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 } |