marrow / WebCore

WebCore, the super tiny and blazingly fast modular Python web nanoframework.
MIT License
94 stars 10 forks source link

HTTPException instances caught fail to preserve important response headers. #179

Closed amcgregor closed 3 years ago

amcgregor commented 7 years ago

Notably especially for CORS, certain headers should be preserved regardless of final outcome, such as the Allow header identifying the HTTP verbs that are allowed, a la an OPTIONS request. Exceptions generated by extensions (such as ACL verification failure, incoming data transformation) or via in-endpoint raise currently replace context.response with the exception (since it is a valid WSGI application and Response instance), nuking any cooperative changes that have been made to the original.

On exception, all response headers excepting content headers should be transferred.

amcgregor commented 3 years ago

HTTP exceptions are caught and utilized as if they were a value returned by the endpoint, ultimately applied to the context by the BaseExtension registered render_response view, as HTTPException objects are themselves Response instances, WSGI applications. 2840daf now transfers a subset of headers from the existing cooperatively-populated Response instance: