问题描述
要在应用程序引擎中获取(获取)超过1M的代码,我使用range标头,然后将这些代码段和我的代码结合起来
to fetch() over 1M in app engine,i use the range header and then combine those pieces.and my codes:
int startpos=0;
int endpos;
int seg=1;
int len=1;
while(len>0){
endpos=startpos+seg;
httpConn = (HttpURLConnection) u.openConnection();
httpConn.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
con.setRequestProperty("Range", "bytes=" + startpos + "-" + endpos);
con.connect();
InputStream in=con.getInputStream();
len=con.getContentLength();
byte[] b=new byte[len];
in.read(b, 0, len);
startpos+=len;
}但是当转到"InputStream in = con.getInputStream();"时,其调试为"URL提取响应太大问题"所以我不知道这些代码有什么问题.还有其他方法可以获取超过1M的数据吗?
}but when it goes to the "InputStream in=con.getInputStream();",its debug is " URL Fetch Response too large problems"so i don't know what the wrong with these codes.and there are other ways to fetch() over 1M?
推荐答案
并非所有的HTTP服务器都支持范围请求,特别是涉及到提供动态内容的框架时,它们将简单地忽略Range标头并向您发送整个响应.
Not all HTTP servers support range requests, especially when it comes to frameworks serving dynamic content - they'll simply ignore the Range header and send you the whole response.
不过,最新版本1.4.0将URLFetch响应限制增加到32MB,因此您不再需要这样做.
The recent release of 1.4.0 increased the URLFetch response limit to 32MB, though, so you no longer need to do this.
这篇关于应用引擎中的urlfetch超过1M的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!