litesuits / litesuits/android-lite-http

取消网络请求时,数据还在继续下载

Open
#21 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
817
Forks
337
PR merge metrics
No merged PRs in 30d

Description

在调用了request.cancel()后,表面上看起来像是取消下载了,但实质服务器还能给客户端发数据。
分析了原因,是因为DataParser中stream.close()不能立即关闭,需要接收完全部数据,inputstream才能关闭导致。这说明数据链路还是连接的,这样取消下载就没什么意义,还是会消耗流量,但我不知道怎么修改,有大牛知道怎么修改吗?
public T readFromNetStream(InputStream stream, long len,
String charSet) throws IOException {
if (stream != null) {
try {
this.data = parseNetStream(stream, len, charSet);
} finally {
stream.close();
}
}
return this.data;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing request.cancel() into DataParser.readFromNetStream(InputStream stream, long len, String charSet), then inspect parseNetStream and the stream.close() call shown in the issue. Reproduce cancellation while data is still downloading and verify whether the network stream remains active; done means cancellation stops further data transfer without breaking normal parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.