Skip to content

keep response headers on redirect (30x)#387

Merged
nggit merged 1 commit intomainfrom
redirect
Feb 4, 2026
Merged

keep response headers on redirect (30x)#387
nggit merged 1 commit intomainfrom
redirect

Conversation

@nggit
Copy link
Owner

@nggit nggit commented Feb 2, 2026

# case 1
response.set_header('Set-Cookie', 'xxx')
raise Forbidden  # 403, previous headers including cookies are cleared, OK so far

# case 2
response.set_header('Set-Cookie', 'xxx')
raise HTTPRedirect  # 30x, feel suck if also cleared. This PR prevents clear()

# case 3
# to reliably set headers on exception is via its kwargs
raise Forbidden('you are not allowed', set_cookie='xxx')  # **kwargs are translated as response headers

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

@nggit nggit merged commit b1f04ba into main Feb 4, 2026
23 checks passed
@nggit nggit deleted the redirect branch February 4, 2026 10:16
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