Skip to content

fix(http): refine Proxy-Authenticate basic auth workflow#103

Closed
tianhuyang wants to merge 5 commits into
SagerNet:devfrom
tianhuyang:fix/http-proxy-auth-header-comma
Closed

fix(http): refine Proxy-Authenticate basic auth workflow#103
tianhuyang wants to merge 5 commits into
SagerNet:devfrom
tianhuyang:fix/http-proxy-auth-header-comma

Conversation

@tianhuyang

@tianhuyang tianhuyang commented Jun 22, 2026

Copy link
Copy Markdown

Summary

This PR extends the original HTTP proxy auth header formatting fix with follow-up reliability and observability improvements in protocol/http/handshake.go.

What Changed

  • Kept the Proxy-Authenticate header formatting fix:
    • Basic realm="sing-box", charset="UTF-8"
  • Added one-time retry for missing Proxy-Authorization when retry is safe.
  • Added configurable retry timeout through HTTPServerOptions.ProxyAuthRetryTimeout (default 5s).
  • Migrated handshake logging to repository logger abstraction:
    • Added HTTPServerOptions.Logger (logger.ContextLogger) with logger.NOP() fallback.
    • Logged request protocol and response protocol+status.
    • Logged request/response headers in deterministic key order.
  • Redacted sensitive header values in logs:
    • Authorization, Proxy-Authorization, Cookie, Set-Cookie.
  • Preserved retry safety constraints:
    • no retry on upgrade,
    • no retry for requests with body/transfer-encoding,
    • keep-alive aware behavior across HTTP/1.0 and HTTP/1.1 semantics.

Tests

Added/updated tests in protocol/http/handshake_test.go, including:

  • retry success/once/timeout behavior,
  • HTTP/1.0 keep-alive and default-close cases,
  • no-retry on upgrade and request body,
  • logger emission checks,
  • sensitive-header redaction checks.

Validation

  • CGO_ENABLED=0 go test ./protocol/http
  • CGO_ENABLED=0 go test ./...

Notes

This PR now covers the full set of HTTP proxy auth handshake updates currently on branch fix/http-proxy-auth-header-comma.

@tianhuyang tianhuyang changed the title fix(http): add comma in Proxy-Authenticate Basic params fix(http): format Proxy-Authenticate challenge params Jun 22, 2026
@tianhuyang

Copy link
Copy Markdown
Author

@nekohasekai @wwqgtxx could you please take a look at this small header-format fix when convenient? Thank you.

@tianhuyang tianhuyang force-pushed the fix/http-proxy-auth-header-comma branch from 2ae5b05 to 6c597e4 Compare June 23, 2026 10:11
@tianhuyang tianhuyang changed the title fix(http): format Proxy-Authenticate challenge params fix(http): refine Proxy-Authenticate basic auth workflow Jun 23, 2026
@tianhuyang

Copy link
Copy Markdown
Author

Not needed

@tianhuyang tianhuyang closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant