Repository navigation
⚡ Bolt: FastAPI 핫패스 병목 제거 #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,7 +71,11 @@ def _apply_security_headers(response: Response, request: Request) -> Response: | |||||
| response.headers["Referrer-Policy"] = "no-referrer" | ||||||
| response.headers["Cache-Control"] = "no-store, no-cache, max-age=0" | ||||||
| forwarded_proto = request.headers.get("x-forwarded-proto", "") | ||||||
| is_https = request.url.scheme == "https" or forwarded_proto.lower() == "https" | ||||||
| # ⚡ Bolt: Use scope["scheme"] to avoid expensive request.url parsing overhead | ||||||
| is_https = ( | ||||||
| request.scope.get("scheme", "http") == "https" | ||||||
| or forwarded_proto.lower() == "https" | ||||||
| ) | ||||||
| if is_https: | ||||||
| response.headers["Strict-Transport-Security"] = ( | ||||||
| "max-age=31536000; includeSubDomains" | ||||||
|
|
@@ -94,7 +98,8 @@ def _authorization_values(request: Request) -> list[bytes]: | |||||
| return [ | ||||||
| value | ||||||
| for name, value in request.scope.get("headers", []) | ||||||
| if name.lower() == b"authorization" | ||||||
| # ⚡ Bolt: ASGI servers guarantee lowercase header names in scope | ||||||
| if name == b"authorization" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 대문자 인증 헤더의 잘못된 거부 ASGI 스코프가 Learn moreASGI의 Example: Recommended fix: 이름 비교를 대소문자 무관하게 복원하고, 대문자 헤더 하나와 대소문자가 다른 중복 헤더에 대한 ASGI 스코프 테스트를 추가하세요.
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||
| ] | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: ContextualWisdomLab/newsdom-api
Length of output: 6591
🌐 Web query:
ASGI HTTP specification header names should be lowercased but not required exact wording💡 Result:
ASGI 헤더 대소문자 설명을 사양과 지원 서버에 맞게 수정하세요.
ASGI HTTP 사양은 수신 헤더 이름의 소문자화를 권고하지만 보장하지 않습니다. 다만 이 저장소가 사용하는 Uvicorn 0.44.0의 h11 및 httptools 경로는
scope["headers"]에 넣기 전에 이름을 소문자로 변환합니다. 따라서 현재 지원 구성에서는 혼합 대소문자Authorization이 이 비교에서 누락되지 않습니다. 런타임 결함으로 설명하지 말고, ASGI 사양과 현재 Uvicorn 동작을 구분해 기록하세요.권장 문구
📝 Committable suggestion
🤖 Prompt for AI Agents