7Here we'll look at a simple example of fetching a remote HTTP resource with Iris. We'll use the following thread, which you can save in the `/ted` directory of your `%base` desk:
14=, strand=strand:spider
19=/ url=@t (need !<((unit @t) arg))
20=/ =request:http [%'GET' url ~ ~]
21=/ =task:iris [%request request *outbound-config:iris]
22=/ =card:agent:gall [%pass /http-req %arvo %i task]
23;< ~ bind:m (send-raw-card:strandio card)
24;< res=(pair wire sign-arvo) bind:m take-sign-arvo:strandio
25?. ?=([%iris %http-response %finished *] q.res)
26 (strand-fail:strand %bad-sign ~)
28?~ full-file.client-response.q.res
29 (strand-fail:strand %no-body ~)
30(pure:m !>(`@t`q.data.u.full-file.client-response.q.res))
33This thread takes a fully qualified URL in a `@t` as an argument. It will ask Iris to fetch the HTTP resource at the given URL by passing it a [%request task](/docs/arvo/iris/tasks#request) containing an HTTP GET [$request:http](/docs/arvo/eyre/data-types#requesthttp):
36=/ url=@t (need !<((unit @t) arg))
37=/ =request:http [%'GET' url ~ ~]
38=/ =task:iris [%request request *outbound-config:iris]
39=/ =card:agent:gall [%pass /http-req %arvo %i task]
42In this example, our `request:http` specifies no additional headers and has no body so it has a `~` for each of those fields. Of course in practice if you have headers or data you want to send you would include those.
44Our thread will take the `%http-response` `gift` that comes back from Iris and debug print it to the terminal so you can have a look at the structure, and then it will cast the body of the HTTP message to a `@t` and print it.
49> -iris-thread 'http://example.com'
57 [key='age' value='212909']
58 [key='cache-control' value='max-age=604800']
59 [key='content-type' value='text/html; charset=UTF-8']
60 [key='date' value='Thu, 24 Jun 2021 04:12:13 GMT']
61 [key='expires' value='Thu, 01 Jul 2021 04:12:13 GMT']
62 [key='last-modified' value='Thu, 17 Oct 2019 07:18:26 GMT']
63 [key='server' value='ECS (oxr/8328)']
64 [key='vary' value='Accept-Encoding']
65 [key='x-cache' value='HIT']
66 [key='content-length' value='1256']
71 [ type='text/html; charset=UTF-8'
75 224.708.415.080.409.844.273.808.970.700.472.455.882.111.359.8(...truncated for brevity)
83...and here's the data from the HTTP response cast to a `@t`:
86'<!doctype html>\0a<html>\0a<head>\0a <title>Example Domain</title>\0a\0a (...truncated for brevity)'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list