Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Simplify/fix code after the recent fix for no. 1013
Browse files Browse the repository at this point in the history
  • Loading branch information
vfaronov committed Jul 19, 2017
1 parent 0c22bb9 commit d24af60
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions httpolice/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __contains__(self, other):
def _compare(self, other, op):
# It would be nice to be able to compare headers by values, as in::
#
# response.headers.etag == request.headers.if_match
# resp.headers.last_modified == req.headers.if_modified_since
#
# Unfortunately, there are places
# (such as :meth:`httpolice.blackboard.Blackboard.complain`)
Expand All @@ -218,7 +218,7 @@ def _compare(self, other, op):
#
# Now, the following form still works::
#
# response.headers.etag == request.headers.if_match.value
# resp.headers.last_modified == req.headers.if_modified_since.value
#
# so we don't lose all that much.

Expand Down
5 changes: 2 additions & 3 deletions httpolice/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ def check_request(req):
if x.item in [cc.x_gzip, cc.x_compress] and x.param is not None:
complain(1116, coding=x.item)

if headers.if_match.is_okay and headers.if_match != u'*':
if any(tag.weak for tag in headers.if_match):
complain(1120)
if headers.if_match != u'*' and any(tag.weak for tag in headers.if_match):
complain(1120)

if method == m.HEAD:
for hdr in headers:
Expand Down
5 changes: 2 additions & 3 deletions httpolice/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def check_response_in_context(resp, req):
complain(1115)

if method in [m.GET, m.HEAD] and status.successful:
if req.headers.if_none_match.is_okay and resp.headers.etag.is_okay:
if resp.headers.etag.is_okay:
if req.headers.if_none_match == u'*':
# In this case we could ignore the presence of ``ETag``,
# but then we would need a separate notice
Expand Down Expand Up @@ -737,8 +737,7 @@ def check_response_in_context(resp, req):

if resp.headers.preference_applied.is_present and \
known.method.is_cacheable(method) and \
not (resp.headers.vary == u'*') and \
not (resp.headers.vary.is_okay and h.prefer in resp.headers.vary):
resp.headers.vary != u'*' and h.prefer not in resp.headers.vary:
# We could also look for ``Cache-Control: no-store`` etc.,
# but the meaning of ``Vary`` is not limited to caching,
# and anyway this is just a mild comment.
Expand Down

0 comments on commit d24af60

Please sign in to comment.