Conditions | 7 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | # -*- coding: utf-8 -*- |
||
15 | def conditional_http_tween(request): |
||
16 | response = handler(request) |
||
17 | |||
18 | if request.path not in not_cacheble_list: |
||
19 | |||
20 | # If the Last-Modified header has been set, we want to enable the |
||
21 | # conditional response processing. |
||
22 | if response.last_modified is not None: |
||
23 | response.conditional_response = True |
||
24 | |||
25 | # We want to only enable the conditional machinery if either we |
||
26 | # were given an explicit ETag header by the view or we have a |
||
27 | # buffered response and can generate the ETag header ourself. |
||
28 | if response.etag is not None: |
||
29 | response.conditional_response = True |
||
30 | elif (isinstance(response.app_iter, Sequence) and |
||
31 | len(response.app_iter) == 1) and response.body is not None: |
||
32 | response.conditional_response = True |
||
33 | response.md5_etag() |
||
34 | |||
35 | return response |
||
36 | |||
38 |