| 1 |
= Chunked hello world example |
| 2 |
|
| 3 |
To try this example, you need GNU `make` and `git` in your PATH. |
| 4 |
|
| 5 |
To build and run the example, use the following command: |
| 6 |
|
| 7 |
[source,bash] |
| 8 |
$ make run |
| 9 |
|
| 10 |
Then point your browser to http://localhost:8080 |
| 11 |
or use `curl` to see the chunks arriving one at a time every second. |
| 12 |
|
| 13 |
== HTTP/1.1 example output |
| 14 |
|
| 15 |
[source,bash] |
| 16 |
---- |
| 17 |
$ time curl -i http://localhost:8080 |
| 18 |
HTTP/1.1 200 OK |
| 19 |
transfer-encoding: chunked |
| 20 |
connection: keep-alive |
| 21 |
server: Cowboy |
| 22 |
date: Fri, 28 Sep 2012 04:24:16 GMT |
| 23 |
|
| 24 |
Hello |
| 25 |
World |
| 26 |
Chunked! |
| 27 |
curl -i http://localhost:8080 0.01s user 0.00s system 0% cpu 2.015 total |
| 28 |
---- |
| 29 |
|
| 30 |
== HTTP/2 example output |
| 31 |
|
| 32 |
[source,bash] |
| 33 |
---- |
| 34 |
$ nghttp -v http://localhost:8080 |
| 35 |
[ 0.000] Connected |
| 36 |
[ 0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0> |
| 37 |
(niv=2) |
| 38 |
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100] |
| 39 |
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535] |
| 40 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3> |
| 41 |
(dep_stream_id=0, weight=201, exclusive=0) |
| 42 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5> |
| 43 |
(dep_stream_id=0, weight=101, exclusive=0) |
| 44 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7> |
| 45 |
(dep_stream_id=0, weight=1, exclusive=0) |
| 46 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9> |
| 47 |
(dep_stream_id=7, weight=1, exclusive=0) |
| 48 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11> |
| 49 |
(dep_stream_id=3, weight=1, exclusive=0) |
| 50 |
[ 0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13> |
| 51 |
; END_STREAM | END_HEADERS | PRIORITY |
| 52 |
(padlen=0, dep_stream_id=11, weight=16, exclusive=0) |
| 53 |
; Open new stream |
| 54 |
:method: GET |
| 55 |
:path: / |
| 56 |
:scheme: http |
| 57 |
:authority: localhost:8080 |
| 58 |
accept: */* |
| 59 |
accept-encoding: gzip, deflate |
| 60 |
user-agent: nghttp2/1.7.1 |
| 61 |
[ 0.006] recv SETTINGS frame <length=0, flags=0x00, stream_id=0> |
| 62 |
(niv=0) |
| 63 |
[ 0.006] recv SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 64 |
; ACK |
| 65 |
(niv=0) |
| 66 |
[ 0.006] send SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 67 |
; ACK |
| 68 |
(niv=0) |
| 69 |
[ 0.010] recv (stream_id=13) :status: 200 |
| 70 |
[ 0.010] recv (stream_id=13) date: Mon, 13 Jun 2016 14:16:26 GMT |
| 71 |
[ 0.010] recv (stream_id=13) server: Cowboy |
| 72 |
[ 0.010] recv HEADERS frame <length=32, flags=0x04, stream_id=13> |
| 73 |
; END_HEADERS |
| 74 |
(padlen=0) |
| 75 |
; First response header |
| 76 |
Hello |
| 77 |
[ 0.010] recv DATA frame <length=7, flags=0x00, stream_id=13> |
| 78 |
World |
| 79 |
[ 1.012] recv DATA frame <length=7, flags=0x00, stream_id=13> |
| 80 |
Chunked! |
| 81 |
[ 2.013] recv DATA frame <length=10, flags=0x00, stream_id=13> |
| 82 |
[ 2.013] recv DATA frame <length=0, flags=0x01, stream_id=13> |
| 83 |
; END_STREAM |
| 84 |
[ 2.013] send GOAWAY frame <length=8, flags=0x00, stream_id=0> |
| 85 |
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[]) |
| 86 |
---- |