fix: respect proxy when probing download URLs - #325
Open
Radiums wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
嘿——我发现了 1 个问题
面向 AI Agent 的提示
请处理本次代码审查中的评论:
## 个别评论
### 评论 1
<location path="src-tauri/src/commands/download.rs" line_range="629-632" />
<code_context>
+ let proxy_address = listener.local_addr().expect("get test proxy address");
+ let proxy = std::thread::spawn(move || {
+ let (mut stream, _) = listener.accept().expect("accept proxied request");
+ let mut request = [0_u8; 2048];
+ let bytes_read = stream.read(&mut request).expect("read proxied request");
+ let request = String::from_utf8_lossy(&request[..bytes_read]);
+ assert!(request.starts_with("HEAD http://example.invalid/update.zip HTTP/1.1"));
+ stream
+ .write_all(
</code_context>
<issue_to_address>
**问题(测试):** 回归测试假设一次 `read` 调用会返回完整的 HTTP 请求,并针对该部分缓冲区进行断言。TCP 读取没有消息边界,因此当一个有效的代理请求被拆分到多个数据包中时,该断言会间歇性失败。
**触发条件:** 代理请求的请求头分散在多个 TCP 段中到达时。
**建议修复:** 在断言请求行之前循环读取,直到收到 `\r\n\r\n` 请求头结束符。
```suggestion
let mut request = Vec::new();
loop {
let mut chunk = [0_u8; 2048];
let bytes_read = stream.read(&mut chunk).expect("read proxied request");
assert!(bytes_read > 0, "proxy closed before request headers");
request.extend_from_slice(&chunk[..bytes_read]);
if request.windows(4).any(|window| window == b"\r\n\r\n") {
break;
}
}
let request = String::from_utf8_lossy(&request);
assert!(request.starts_with("HEAD http://example.invalid/update.zip HTTP/1.1"));
```
</issue_to_address>帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用这些反馈来改进审查。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/commands/download.rs" line_range="629-632" />
<code_context>
+ let proxy_address = listener.local_addr().expect("get test proxy address");
+ let proxy = std::thread::spawn(move || {
+ let (mut stream, _) = listener.accept().expect("accept proxied request");
+ let mut request = [0_u8; 2048];
+ let bytes_read = stream.read(&mut request).expect("read proxied request");
+ let request = String::from_utf8_lossy(&request[..bytes_read]);
+ assert!(request.starts_with("HEAD http://example.invalid/update.zip HTTP/1.1"));
+ stream
+ .write_all(
</code_context>
<issue_to_address>
**issue (testing):** The regression test assumes one `read` call returns the complete HTTP request and asserts against that partial buffer. TCP reads are not message-framed, so a valid proxied request split across packets causes the assertion to fail intermittently.
**Triggers:** When the proxy request headers arrive in multiple TCP segments.
**Suggested fix:** Read in a loop until the `\r\n\r\n` header terminator is received before asserting the request line.
```suggestion
let mut request = Vec::new();
loop {
let mut chunk = [0_u8; 2048];
let bytes_read = stream.read(&mut chunk).expect("read proxied request");
assert!(bytes_read > 0, "proxy closed before request headers");
request.extend_from_slice(&chunk[..bytes_read]);
if request.windows(4).any(|window| window == b"\r\n\r\n") {
break;
}
}
let request = String::from_utf8_lossy(&request);
assert!(request.starts_with("HEAD http://example.invalid/update.zip HTTP/1.1"));
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Owner
|
没看懂,这干嘛的,现在 github 不是有代理吗? |
Author
fallback的时候没走代理 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HEADprobeProblem
The GitHub Release API request respects the app's update proxy, but its fallback path probes constructed release URLs with
tauriFetch. ThatHEADrequest does not receive the app-configured proxy, so users who rely on the update proxy can fail before the actual package download starts.Testing
tsc)probe_download_url_uses_explicit_proxyregression testThe Rust test could not be linked locally because MSVC
link.exeis unavailable on this machine; the application code will be compiled by the repository's Windows CI.Sourcery 摘要
通过配置的代理路由备用下载 URL 探测,以支持在使用代理的环境中进行更新。
新功能:
错误修复:
增强功能:
测试:
Original summary in English
Sourcery 总结
通过配置的更新代理路由备用下载 URL 探测请求。
新功能:
错误修复:
增强功能:
测试:
Original summary in English
Summary by Sourcery
Route fallback download URL probes through the configured update proxy.
New Features:
Bug Fixes:
Enhancements:
Tests: