【发布时间】:2010-12-12 12:55:50
【问题描述】:
要在应用引擎中 fetch() 超过 1M,我使用范围标头,然后结合这些部分。和我的代码:
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 Fetch Response too large questions” 所以我不知道这些代码有什么问题。 还有其他方法可以 fetch() 超过 1M 吗?
【问题讨论】:
-
该代码甚至不应该编译,因为您已经两次声明了
b... -
逐块请求它而不是请求一次并逐块读取有什么好处吗?请注意,您的代码不会编译,因为您已经声明了两次
b。 -
App engine Urlfetch over 1M? 的可能重复项
标签: java google-app-engine urlfetch