| 1 |
= Compressed response 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 |
|
| 12 |
== HTTP/1.1 example output |
| 13 |
|
| 14 |
Without compression: |
| 15 |
|
| 16 |
[source,bash] |
| 17 |
---- |
| 18 |
$ curl -i http://localhost:8080 |
| 19 |
HTTP/1.1 200 OK |
| 20 |
connection: keep-alive |
| 21 |
server: Cowboy |
| 22 |
date: Mon, 07 Jan 2013 18:42:29 GMT |
| 23 |
content-length: 909 |
| 24 |
|
| 25 |
A cowboy is an animal herder who tends cattle on ranches in North America, |
| 26 |
traditionally on horseback, and often performs a multitude of other ranch- |
| 27 |
related tasks. The historic American cowboy of the late 19th century arose |
| 28 |
from the vaquero traditions of northern Mexico and became a figure of special |
| 29 |
significance and legend. A subtype, called a wrangler, specifically tends the |
| 30 |
horses used to work cattle. In addition to ranch work, some cowboys work for |
| 31 |
or participate in rodeos. Cowgirls, first defined as such in the late 19th |
| 32 |
century, had a less-well documented historical role, but in the modern world |
| 33 |
have established the ability to work at virtually identical tasks and obtained |
| 34 |
considerable respect for their achievements. There are also cattle handlers |
| 35 |
in many other parts of the world, particularly South America and Australia, |
| 36 |
who perform work similar to the cowboy in their respective nations. |
| 37 |
---- |
| 38 |
|
| 39 |
With compression: |
| 40 |
|
| 41 |
[source,bash] |
| 42 |
---- |
| 43 |
$ curl -i --compressed http://localhost:8080 |
| 44 |
HTTP/1.1 200 OK |
| 45 |
connection: keep-alive |
| 46 |
server: Cowboy |
| 47 |
date: Mon, 07 Jan 2013 18:42:30 GMT |
| 48 |
content-encoding: gzip |
| 49 |
content-length: 510 |
| 50 |
|
| 51 |
A cowboy is an animal herder who tends cattle on ranches in North America, |
| 52 |
traditionally on horseback, and often performs a multitude of other ranch- |
| 53 |
related tasks. The historic American cowboy of the late 19th century arose |
| 54 |
from the vaquero traditions of northern Mexico and became a figure of special |
| 55 |
significance and legend. A subtype, called a wrangler, specifically tends the |
| 56 |
horses used to work cattle. In addition to ranch work, some cowboys work for |
| 57 |
or participate in rodeos. Cowgirls, first defined as such in the late 19th |
| 58 |
century, had a less-well documented historical role, but in the modern world |
| 59 |
have established the ability to work at virtually identical tasks and obtained |
| 60 |
considerable respect for their achievements. There are also cattle handlers |
| 61 |
in many other parts of the world, particularly South America and Australia, |
| 62 |
who perform work similar to the cowboy in their respective nations. |
| 63 |
---- |
| 64 |
|
| 65 |
== HTTP/2 example output |
| 66 |
|
| 67 |
Without compression: |
| 68 |
|
| 69 |
[source,bash] |
| 70 |
---- |
| 71 |
$ nghttp -v -H 'accept-encoding: compress' http://localhost:8080 |
| 72 |
[ 0.001] Connected |
| 73 |
[ 0.001] send SETTINGS frame <length=12, flags=0x00, stream_id=0> |
| 74 |
(niv=2) |
| 75 |
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100] |
| 76 |
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535] |
| 77 |
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=3> |
| 78 |
(dep_stream_id=0, weight=201, exclusive=0) |
| 79 |
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=5> |
| 80 |
(dep_stream_id=0, weight=101, exclusive=0) |
| 81 |
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7> |
| 82 |
(dep_stream_id=0, weight=1, exclusive=0) |
| 83 |
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9> |
| 84 |
(dep_stream_id=7, weight=1, exclusive=0) |
| 85 |
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11> |
| 86 |
(dep_stream_id=3, weight=1, exclusive=0) |
| 87 |
[ 0.002] send HEADERS frame <length=45, flags=0x25, stream_id=13> |
| 88 |
; END_STREAM | END_HEADERS | PRIORITY |
| 89 |
(padlen=0, dep_stream_id=11, weight=16, exclusive=0) |
| 90 |
; Open new stream |
| 91 |
:method: GET |
| 92 |
:path: / |
| 93 |
:scheme: http |
| 94 |
:authority: localhost:8080 |
| 95 |
accept: */* |
| 96 |
accept-encoding: compress |
| 97 |
user-agent: nghttp2/1.18.1 |
| 98 |
[ 0.002] recv SETTINGS frame <length=0, flags=0x00, stream_id=0> |
| 99 |
(niv=0) |
| 100 |
[ 0.002] recv SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 101 |
; ACK |
| 102 |
(niv=0) |
| 103 |
[ 0.002] send SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 104 |
; ACK |
| 105 |
(niv=0) |
| 106 |
[ 0.003] recv (stream_id=13) :status: 200 |
| 107 |
[ 0.003] recv (stream_id=13) content-length: 909 |
| 108 |
[ 0.003] recv (stream_id=13) date: Sun, 22 Jan 2017 19:13:47 GMT |
| 109 |
[ 0.003] recv (stream_id=13) server: Cowboy |
| 110 |
[ 0.003] recv HEADERS frame <length=37, flags=0x04, stream_id=13> |
| 111 |
; END_HEADERS |
| 112 |
(padlen=0) |
| 113 |
; First response header |
| 114 |
A cowboy is an animal herder who tends cattle on ranches in North America, |
| 115 |
traditionally on horseback, and often performs a multitude of other ranch- |
| 116 |
related tasks. The historic American cowboy of the late 19th century arose |
| 117 |
from the vaquero traditions of northern Mexico and became a figure of special |
| 118 |
significance and legend. A subtype, called a wrangler, specifically tends the |
| 119 |
horses used to work cattle. In addition to ranch work, some cowboys work for |
| 120 |
or participate in rodeos. Cowgirls, first defined as such in the late 19th |
| 121 |
century, had a less-well documented historical role, but in the modern world |
| 122 |
have established the ability to work at virtually identical tasks and obtained |
| 123 |
considerable respect for their achievements. There are also cattle handlers |
| 124 |
in many other parts of the world, particularly South America and Australia, |
| 125 |
who perform work similar to the cowboy in their respective nations. |
| 126 |
[ 0.003] recv DATA frame <length=909, flags=0x01, stream_id=13> |
| 127 |
; END_STREAM |
| 128 |
[ 0.003] send GOAWAY frame <length=8, flags=0x00, stream_id=0> |
| 129 |
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[]) |
| 130 |
---- |
| 131 |
|
| 132 |
With compression: |
| 133 |
|
| 134 |
[source,bash] |
| 135 |
---- |
| 136 |
$ nghttp -v http://localhost:8080 |
| 137 |
[ERROR] Could not connect to the address ::1 |
| 138 |
Trying next address 127.0.0.1 |
| 139 |
[ 0.000] Connected |
| 140 |
[ 0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0> |
| 141 |
(niv=2) |
| 142 |
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100] |
| 143 |
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535] |
| 144 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3> |
| 145 |
(dep_stream_id=0, weight=201, exclusive=0) |
| 146 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5> |
| 147 |
(dep_stream_id=0, weight=101, exclusive=0) |
| 148 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7> |
| 149 |
(dep_stream_id=0, weight=1, exclusive=0) |
| 150 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9> |
| 151 |
(dep_stream_id=7, weight=1, exclusive=0) |
| 152 |
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11> |
| 153 |
(dep_stream_id=3, weight=1, exclusive=0) |
| 154 |
[ 0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13> |
| 155 |
; END_STREAM | END_HEADERS | PRIORITY |
| 156 |
(padlen=0, dep_stream_id=11, weight=16, exclusive=0) |
| 157 |
; Open new stream |
| 158 |
:method: GET |
| 159 |
:path: / |
| 160 |
:scheme: http |
| 161 |
:authority: localhost:8080 |
| 162 |
accept: */* |
| 163 |
accept-encoding: gzip, deflate |
| 164 |
user-agent: nghttp2/1.18.1 |
| 165 |
[ 0.000] recv SETTINGS frame <length=0, flags=0x00, stream_id=0> |
| 166 |
(niv=0) |
| 167 |
[ 0.000] send SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 168 |
; ACK |
| 169 |
(niv=0) |
| 170 |
[ 0.000] recv SETTINGS frame <length=0, flags=0x01, stream_id=0> |
| 171 |
; ACK |
| 172 |
(niv=0) |
| 173 |
[ 0.000] recv (stream_id=13) :status: 200 |
| 174 |
[ 0.000] recv (stream_id=13) content-encoding: gzip |
| 175 |
[ 0.000] recv (stream_id=13) content-length: 510 |
| 176 |
[ 0.000] recv (stream_id=13) date: Sun, 22 Jan 2017 19:15:16 GMT |
| 177 |
[ 0.000] recv (stream_id=13) server: Cowboy |
| 178 |
[ 0.000] recv HEADERS frame <length=41, flags=0x04, stream_id=13> |
| 179 |
; END_HEADERS |
| 180 |
(padlen=0) |
| 181 |
; First response header |
| 182 |
A cowboy is an animal herder who tends cattle on ranches in North America, |
| 183 |
traditionally on horseback, and often performs a multitude of other ranch- |
| 184 |
related tasks. The historic American cowboy of the late 19th century arose |
| 185 |
from the vaquero traditions of northern Mexico and became a figure of special |
| 186 |
significance and legend. A subtype, called a wrangler, specifically tends the |
| 187 |
horses used to work cattle. In addition to ranch work, some cowboys work for |
| 188 |
or participate in rodeos. Cowgirls, first defined as such in the late 19th |
| 189 |
century, had a less-well documented historical role, but in the modern world |
| 190 |
have established the ability to work at virtually identical tasks and obtained |
| 191 |
considerable respect for their achievements. There are also cattle handlers |
| 192 |
in many other parts of the world, particularly South America and Australia, |
| 193 |
who perform work similar to the cowboy in their respective nations. |
| 194 |
[ 0.000] recv DATA frame <length=510, flags=0x01, stream_id=13> |
| 195 |
; END_STREAM |
| 196 |
[ 0.000] send GOAWAY frame <length=8, flags=0x00, stream_id=0> |
| 197 |
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[]) |
| 198 |
---- |