我可以通过HTTP读取的响应大小是否有限制 [英] Is there a limit of the size of response I can read over HTTP

查看:39
本文介绍了我可以通过HTTP读取的响应大小是否有限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java程序,该程序调用url.url的响应是一个json/string.我必须编写一个程序来从此url获取数据,但是我想知道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?

我要以一种从服务器端获取所有数据的方式来写服务器端(url),但是如果我可以从服务器端获取的大小受到限制,我还可以批量读取吗?

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?

那么,我可以通过HTTP从服务器发送到Java程序的响应大小没有限制吗?

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

此外,我遇到了此链接.最后一个响应是关于大小等于int的,我不确定这是什么意思.如果有人可以解释.

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.

谢谢

推荐答案

HTTP正文的大小没有技术限制.

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

在您引用的链接中,似乎是由解析HTTP的特定对象施加的限制,因为该对象使用int作为大小,这当然是可能的,但与HTTP协议无关.

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.

在HTTP中,您总是必须为另一侧提供内容长度(用于请求和响应),如果您的响应确实很大,则由客户端以可接受的方式处理它(例如直接将其流式传输到文件后端).

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

分组很不错,但这仅适用于以下情况:您(发送较大响应的人)在流化之前不知道响应的实际总大小.如果您事先知道大小,请使用content-length标头.

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.

这篇关于我可以通过HTTP读取的响应大小是否有限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆