Skip to content

fix(http): send python-krex-api/<version> User-Agent by default (data.ex.co.kr WAF blocks python-httpx) - #17

Merged
digitie merged 2 commits into
mainfrom
fix/default-user-agent
Oct 10, 2026
Merged

digitie merged 2 commits into
mainfrom
fix/default-user-agent

Conversation

@digitie

@digitie digitie commented Oct 10, 2026

Copy link
Copy Markdown
Owner

요약

2026-10-08 04:35Z부터 data.ex.co.kr WAF가 흔한 HTTP 라이브러리 기본 User-Agent(python-httpx/*, curl/*)를 400 Request Blocked로 막고 있습니다. 그래서 kor-travel-transport의 highway·휴게소 유가 수집과 kor-travel-weather의 krex_restarea_sync가 실패합니다.

라이브러리가 직접 만드는 session이 기본으로 User-Agent: python-krex-api/<version>을 보내게 합니다. 호출자가 넘긴 session은 헤더를 포함해 그대로 씁니다.

근거(n150 실측)

UA 결과
curl 기본값, python-httpx/0.28.1 400 Request Blocked
브라우저 UA, 서비스 이름 UA, python-krex-api/0.1.0 200

검증

  • 위 방화벽을 흉내 낸 fake에 대한 wire 테스트를 추가했습니다. 수정 전에는 KrexBadRequestError: Request Blocked로 실패하고, 수정 후에는 통과합니다.
  • 호출자가 넘긴 session은 UA도 바뀌지 않고, 라이브러리가 닫지도 않는다는 테스트를 추가했습니다.
  • pytest -m "not live" 226 passed(기준 224), mypy·ruff 통과.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RuoPRjkdpZNYjTZ1RYQoHj

digitie and others added 2 commits October 10, 2026 08:52
data.ex.co.kr WAF가 2026-10-08 13:35 KST 무렵부터 python-httpx/curl 기본 UA를 키·경로와
무관하게 400 Request Blocked로 막는다(KrexBadRequestError). 같은 IP에서 python-krex-api/0.1.0
UA는 통과한다. 버전은 설치된 package metadata에서 읽는다. 주입한 session은 그대로 둔다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RuoPRjkdpZNYjTZ1RYQoHj
@digitie
digitie merged commit 1a37a01 into main Oct 10, 2026
5 checks passed
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