WIZnet Developer Forum

GET message length

Hello,
I’m trying to make http client. w7500 sends GET to server and server sends respond message.
Everything’s OK with messages shorter than ~1890 bytes.
If server sends longer message, size = getSn_RX_RSR(sn) always returns 1460.
I’ve found that server splits long message into shorter packages (length =1460).
How can I determine the number of packages?
Thank you.

TCP/IP is a streaming protocol not a datagram protocol.
The ethernet frame defaults to 1460 bytes, that is the number you see.
You should always remember that the server is free to send data one (1) byte at a time per ethernet frame and handle that case.
Data can flow in both directions as long as socket is connected.
Maybe you can parse the header of the response for eg. “Content-Length: 1234\n” and determine how many bytes you want to read after the header?
If no content-length header is given in http-response you have to find another way. (maybe read until connection close?)
If you use http/1.1 connection keep-alive is something to take into account.
Also read up on “Transfer-Encoding: chunked” if you send a http/1.1 request to a server it is always allowed to send a chunked response.

Hope that helps,
Edwin van den Oetelaar

Thank you for your response.
I think I’ve managed to solve the problem comparing Content-length and frame size values.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.