Commit 51a3b4b
committed
net: http: server: Enable HTTP1.0 request compatibility
Per RFC9112 (REF #1), HTTP/1.1 server is expected to be backward
compatible with HTTP1.0 request. Mainly HTTP/1.0 does
not support
1) Transfer Encoding : chunked
2) KeepAlives
So, this change will identify the HTTP protocol
version in the request and respond accordingly.
REF#
1) https://httpwg.org/specs/rfc9112.html
Tested:
1) Verified that HTTP/1.1 requests are served as usual
i.e. with chunked transfer encoding and the connection
is a Keep Alive connection
Query exits after 10s, indicating that the client connection to
the HTTP server is a Keep Alive.
```
time printf "GET /telem HTTP/1.1\r\nHost: 192.0.3.11\r\n\r\n" |
nc 192.0.3.11 80
real 0m10.185s <- Indicates connection was kept active for 10s
user 0m0.023s
sys 0m0.023s
```
`Transfer Encoding : chunked` header and chunked encoding
metadata (chunk size hex bytes, crlf, termination byte 0)
are present in the response.
```
HTTP/1.1 200 OK
Transfer-Encoding: chunked <- Chunked encoding header
Content-Type: text/html
3e8 <- Chunk size hex bytes
:
/health/secondsdevice_ae:9a:22:48:0f:70"seconds0
+
/health/locatedevice_ae:9a:22:48:0f:70"0
/
/network/mac-addressdevice_ae:9a:22:48:0f:70"
.
.
.
3e8 <- Chunk size hex byte
_PLUS_rawdevice_ae:9a:22:48:0f:70"0
6
/dev/ISHARE_CBU_MINUS_rawdevice_ae:9a:22:48:0f:70"0
.
.
.
/dev/part_iddevice_ae:9a:22:48:0f:70"0���������
,
/dev/part_typedevice_ae:9a:22:48:0f:70"0
7
/dev/part_telemetry_disabledevice_ae:9a:22:48:0f:70"0
0 <- Termination Byte 0
```
2) Verfied that HTTP/1.0 requests are served with
response without chunked transfer encoding and the
connection is closed immediately.
Query exits immediately indicating the connection is closed immediately
```
time printf "GET /telem HTTP/1.0\r\nHost: 192.0.3.11\r\n\r\n" |
nc 192.0.3.11 80
real 0m0.186s <- Indicates connection was terminated immediately.
user 0m0.018s
sys 0m0.030s
```
`Transfer Encoding : chunked` header and chunked encoding
metadata (chunk size hex bytes, crlf) not present in the
response
```
HTTP/1.1 200 OK
Content-Type: text/html
:
/health/uptimedevice_ae:9a:22:48:0f:70"seconds0
+
/health/locatedevice_ae:9a:22:48:0f:70"0
/
/network/mac-addressdevice_ae:9a:22:48:0f:70"
.
.
.
3
/dev/part_iddevice_ae:9a:22:48:0f:70"0���������
,
/dev/part_typedevice_ae:9a:22:48:0f:70"0
7
/dev/can_telemetry_disabledevice_ae:9a:22:48:0f:70"0
```
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>1 parent 0601335 commit 51a3b4b
1 file changed
+53
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
| |||
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
| 210 | + | |
201 | 211 | | |
202 | 212 | | |
203 | 213 | | |
| |||
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
243 | | - | |
244 | | - | |
245 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
| |||
254 | 267 | | |
255 | 268 | | |
256 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
257 | 274 | | |
258 | | - | |
| 275 | + | |
259 | 276 | | |
260 | 277 | | |
261 | 278 | | |
| |||
358 | 375 | | |
359 | 376 | | |
360 | 377 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
365 | 387 | | |
366 | 388 | | |
367 | 389 | | |
368 | 390 | | |
369 | 391 | | |
370 | 392 | | |
371 | 393 | | |
372 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
373 | 398 | | |
374 | 399 | | |
375 | 400 | | |
| |||
410 | 435 | | |
411 | 436 | | |
412 | 437 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
417 | 444 | | |
418 | 445 | | |
419 | 446 | | |
| |||
490 | 517 | | |
491 | 518 | | |
492 | 519 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
497 | 526 | | |
498 | 527 | | |
499 | 528 | | |
| |||
1111 | 1140 | | |
1112 | 1141 | | |
1113 | 1142 | | |
1114 | | - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
1115 | 1150 | | |
1116 | 1151 | | |
1117 | 1152 | | |
| |||
0 commit comments