twisted / twisted/twisted

twisted.web server keeps caching headers if an exception is raised

Open
#4,897 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug new priority-normal web
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

ivank's avatar ivank reported
Trac ID trac#4897
Type defect
Created 2011-02-18 02:06:35Z

If a resource sets caching headers but then raises an exception, twisted.web.server serves an error page with the existing caching headers. This may cause the error page to be cached.

For example:

def render_GET(self, request):
    request.responseHeaders.setRawHeaders('cache-control', ['max-age=172800, private'])
    request.responseHeaders.setRawHeaders('expires', ['Sun, 20 Feb 2011 01:57:40 GMT'])
    if random.random() < 0.05:
        # Pretend this is a database failure or something
        1/0

In this case, the error page served by twisted.web.server.processingFailed might be cached.

If this problem can be solved by clearing or overriding cache-related headers, twisted.web could help users avoid a non-obvious pitfall. If the right thing to do is to keep the cache-related headers, this behavior should be documented so that users know to catch their own exceptions.

Searchable metadata
trac-id__4897 4897
type__defect defect
reporter__ivank ivank
priority__normal normal
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__web web
keywords__ 
time__1297994795000000 1297994795000000
changetime__1298066267000000 1298066267000000
version__None None
owner__ 
cc__jknight cc__ivank

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting twisted.web.server.processingFailed and the error path described in the report. Reproduce the resource example, then establish whether the intended outcome is to clear or override cache-related headers or to document the existing behavior; done means the chosen behavior is verified for an exception response.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.