Skip to content

fix: add default headers to avoid connection resets (closes #7309)#7311

Open
botbikamordehai2-sketch wants to merge 1 commit into
akfamily:mainfrom
botbikamordehai2-sketch:fix/issue-7309-1781006271
Open

fix: add default headers to avoid connection resets (closes #7309)#7311
botbikamordehai2-sketch wants to merge 1 commit into
akfamily:mainfrom
botbikamordehai2-sketch:fix/issue-7309-1781006271

Conversation

@botbikamordehai2-sketch

Copy link
Copy Markdown

What

The four API endpoints (stock_hsgt_hold_stock_em, stock_hsgt_stock_statistics_em, stock_cg_lawsuit_cninfo, stock_cyq_em) were failing with RemoteDisconnected('Remote end closed connection without response'). This happened because the HTTP requests were sent without proper User-Agent and other headers, causing the server (likely EastMoney) to drop the connection.

Fix

Added default browser-like headers when the caller does not provide them:

  • User-Agent: a standard Chrome/Windows header
  • Accept: application/json, text/plain, */*
  • Accept-Language: zh-CN,zh;q=0.9
  • Referer: https://data.eastmoney.com/ (commonly required by this site)

This change is applied in both make_request_with_retry_json and make_request_with_retry_text exactly before the loop begins, ensuring every request has proper headers.

Closes #7309

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.

AKShare 接口问题报告

1 participant