Mercurial > repos > tabletprog
annotate modules/http.tp @ 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 | |
children | 075b1e71feff |
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 #{ |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 client:usingPort <- :address :port{ |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #{ |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 get <- :path { |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 sock <- socket connectTo: address onPort: port |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 sock send: "GET " . path . " HTTP/1.1\r\nHost: " . address . "\r\n\r\n" |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 resp <- sock recv 4096 |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 print: resp |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 sock close |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 } |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 } |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 } |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 client <- :address { |
7f442b3e4448
Tiny bit of work on HTTP client and sample usage of it
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 client: address usingPort: 80 |
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 } |