Skip to content

net: http: server: Enable HTTP1.0 request compatibility#101631

Merged
fabiobaltieri merged 1 commit intozephyrproject-rtos:mainfrom
namjoshiniks:http-server/HTTP10-request-backward-compatibility
Jan 8, 2026
Merged

net: http: server: Enable HTTP1.0 request compatibility#101631
fabiobaltieri merged 1 commit intozephyrproject-rtos:mainfrom
namjoshiniks:http-server/HTTP10-request-backward-compatibility

Conversation

@namjoshiniks
Copy link
Copy Markdown
Contributor

Per RFC9112 (REF #1), HTTP/1.1 server is expected to be backward compatible with HTTP1.0 requests. Mainly HTTP/1.0 clients do not support

  1. Transfer Encoding : chunked
  2. KeepAlive connections

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
  1. 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

@zephyrbot zephyrbot added area: HTTP HTTP client/server support area: Networking labels Dec 30, 2025
@namjoshiniks namjoshiniks force-pushed the http-server/HTTP10-request-backward-compatibility branch from d259089 to 51a3b4b Compare December 30, 2025 22:33
@namjoshiniks namjoshiniks force-pushed the http-server/HTTP10-request-backward-compatibility branch from 51a3b4b to d84c737 Compare December 31, 2025 03:49
@namjoshiniks namjoshiniks requested a review from yvesll December 31, 2025 03:51
Copy link
Copy Markdown
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just couple of coding style nits.

Per RFC9112 (REF zephyrproject-rtos#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 <[email protected]>
@namjoshiniks namjoshiniks force-pushed the http-server/HTTP10-request-backward-compatibility branch from d84c737 to df60aa6 Compare January 2, 2026 18:12
@namjoshiniks namjoshiniks requested a review from jukkar January 2, 2026 18:20
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 2, 2026

@namjoshiniks
Copy link
Copy Markdown
Contributor Author

Looks good, just couple of coding style nits.

Thanks for the review. I addressed all the inputs.

@fabiobaltieri fabiobaltieri merged commit 9151a32 into zephyrproject-rtos:main Jan 8, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: HTTP HTTP client/server support area: Networking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants