Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

java - Is there a limit of the size of response I can read over HTTP

I have a java program, that calls a url. The response of url is a json/string. I have to write a program that fetches the data from this url, but I was wondering if there's a limit on the max size HTTP can pass back?

I was going to write my server side (url) in such a way that it fetches all the data from db, but if there's a limit on the size I can fetch from server, I can do the read in batches also?

So, is there a limit on the size of the response I can send over HTTP from server to my java program?

Also, I came across this link. The last response talks about the size being equal to int, and I am not sure what that means. If someone can explain.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is no technical limit to the size of a HTTP body.

In the link you refer to it seems a limit imposed by a specific object that parses the HTTP because the object uses an int for the size, this is of course possible but not related to the HTTP protocol.

In HTTP you always have to give a content-length to the other side (is both for request & response), if your response is really large, it is up to the client to process it in an acceptable way (e.g. stream it directly to a file backend).

Chunking is nice but it is only meant for when you (the one sending the large response) don't know the actual total size of your response until you have streamed it. If you know the size beforehand, use the content-length header.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...