Skip to content

fix(alicloud_cs): remove incompatible Connection header#84

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/remove-incompatible-headers
Open

fix(alicloud_cs): remove incompatible Connection header#84
Copilot wants to merge 6 commits into
mainfrom
copilot/remove-incompatible-headers

Conversation

Copy link
Copy Markdown

Copilot AI commented May 16, 2026

alicloud_cs.ts was sending HTTP/1.x hop-by-hop headers (not RFC8441-compatible) on request paths that may use HTTP/2.
This change makes header construction protocol-aware: only non-HTTPS paths retain Connection: keep-alive; HTTPS paths omit it.

  • Problem scope

    • AliCloud QR-login/auth request flow used a shared header builder with unconditional Connection.
    • RFC8441 compatibility requires avoiding hop-by-hop headers on H2-capable paths.
  • What changed

    • Introduced URL protocol check in AlipanQRLogin (isHttpsUrl).
    • Refactored header builder to getHeaders(targetUrl) so header decisions are made per request target.
    • Updated all relevant call sites (getOAuthUrl, getLoginPage, generateQRCode, queryQRStatus) to pass their target URL into the header builder.
    • Kept behavior unchanged for non-HTTPS targets by conditionally adding Connection: keep-alive only there.
  • Resulting behavior

    • HTTPS (H2-capable) requests: no Connection header.
    • Non-HTTPS requests: Connection: keep-alive preserved.
private getHeaders(targetUrl: string): Record<string, string> {
  const headers: Record<string, string> = {
    'User-Agent': '...',
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
    'Accept-Encoding': 'gzip, deflate, br',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-site',
    'Referer': 'https://passport.alipan.com/',
    'Origin': 'https://passport.alipan.com'
  };

  if (!this.isHttpsUrl(targetUrl)) {
    headers.Connection = 'keep-alive';
  }
  return headers;
}

jyxjjj
jyxjjj previously requested changes May 16, 2026
Copy link
Copy Markdown
Member

@jyxjjj jyxjjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

等我白天改,Copilot真不如GPT,这样改动还不如直接删下请求头,看来是我提示词说太多了

Copilot AI requested a review from jyxjjj May 16, 2026 15:26
Copilot stopped work on behalf of jyxjjj due to an error May 16, 2026 15:26
jyxjjj added 2 commits May 17, 2026 04:59
Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
@jyxjjj jyxjjj marked this pull request as ready for review May 17, 2026 05:01
@jyxjjj jyxjjj dismissed their stale review May 17, 2026 05:01

I have reverted AI's edition & force pushed

@jyxjjj jyxjjj changed the title alicloud_cs: gate RFC8441-incompatible Connection header by protocol and apply across AliCloud auth requests fix(alicloud_cs): remove incompatible Connection header May 17, 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.

2 participants