I have an HTTP server listening on a specific TCP port written in Golang. I have a logic that the server will reject the client request if the client payload is larger than a certain size. Now I'm wondering if the total size of the user data is also negotiated in the TCP handshake or not?
Asked
Active
Viewed 30 times
-1
-
1TCP is only concerned with individual, ordered, packets, not application-layer operations. – Dai May 04 '23 at 11:25
-
Also, your question assumes HTTP uses TCP - [when in fact HTTP supports UDP just fine](https://stackoverflow.com/questions/323351/does-http-use-udp). – Dai May 04 '23 at 11:26
1 Answers
0
I have a logic that the server will reject the client request if the client payload is larger than a certain size
I assume you're doing this by verifying the Request's Content-Length
header against the actual aggregate data received.
Now I'm wondering if the total size of the user data is also negotiated in the TCP handshake or not?
No, it isn't.
- First, your question assumes HTTP uses TCP - when in fact HTTP supports UDP just fine, and HTTP/3 uses QUIC (which itself is built-on UDP).
- And you can probably still get HTTP to run over IPX/SPX.
- TCP itself is a lower-level protocol compared to HTTP: TCP is only concerned with ensuring reliable transmission of TCP packets, and in a HTTP connection those TCP packets could contain headers, request/response content, trailing headers, WebSocket/SSE data, and more besides.
- If you were to look at the structure of TCP packet headers, you'll see it doesn't contain any fields for any kind of request payload length.

Dai
- 141,631
- 28
- 261
- 374