Repository navigation
fix: no_proxy 兜底不再覆盖用户原有的 bypass 列表,补 5 个单测 - #38
Merged
Merged
Conversation
#34 的 follow-up。os.environ.get("no_proxy", os.environ.get("NO_PROXY", "")) 在 key 存在但值为空串时返回 "",default 分支不执行 —— 读不到 NO_PROXY,接着 把它整个覆盖成 "127.0.0.1,localhost"。POSIX 上这俩是独立变量所以能真触发; httpx 也读它们,用户的内网 bypass 规则会连带失效。 顺带:追加而不是 sorted(set) 重排,保留原有顺序;按小写去重,避免已有 LOCALHOST 时每次启动列表都变长。补 5 个单测(原 PR 没有)。
longsizhuo
force-pushed
the
fix/pr34-followup
branch
from
August 4, 2026 20:04
3733fb9 to
263604b
Compare
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.
#34 的 follow-up。修法本身是对的(核过:
HTTPApi._request走urllib.request.urlopen,ProxyHandler.proxy_open每次请求都现调proxy_bypass重读 env,所以起浏览器前设一次就生效),但实现有个真 bug,另外没单测。Bug:
no_proxy被显式设成空串时会丢掉用户原有的 bypass 列表。key 存在但值为空串时
get返回"",default 分支根本不执行 —— 读不到NO_PROXY,接着下面把它整个覆盖成127.0.0.1,localhost。POSIX 上这俩是独立变量所以能真触发(Windows 的os.environ大小写不敏感,碰不到)。httpx也读这两个变量,所以用户的公司内网 bypass 规则会在跑脚本期间静默失效。顺带两条:追加而不是
sorted(set)重排,保留原有顺序;按小写去重,避免已有LOCALHOST时每次启动列表都变长一截。补 5 个单测,原 PR 一个都没有。其中
falls_back_to_uppercase是上面那个 bug 的回归测试,只在 POSIX 上真正生效,CI 跑 ubuntu 所以能覆盖。208 passed, 1 skipped。