Merge lp:~cjwatson/lazr.restful/py3-etag into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 268
Proposed branch: lp:~cjwatson/lazr.restful/py3-etag
Merge into: lp:lazr.restful
Diff against target: 12 lines (+1/-1)
1 file modified
src/lazr/restful/_resource.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-etag
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+390358@code.launchpad.net

Commit message

Fix ETag calculation on Python 3.

Description of the change

We need to encode the media type before hashing it.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/_resource.py'
2--- src/lazr/restful/_resource.py 2020-09-04 10:21:08 +0000
3+++ src/lazr/restful/_resource.py 2020-09-07 09:42:38 +0000
4@@ -442,7 +442,7 @@
5
6 # Append the media type, so that web browsers won't treat
7 # different representations of a resource interchangeably.
8- core_hashes[-1].update("\0" + media_type)
9+ core_hashes[-1].update(("\0" + media_type).encode("UTF-8"))
10
11 etag = '"%s"' % "-".join([core.hexdigest() for core in core_hashes])
12 self.etags_by_media_type[media_type] = etag

Subscribers

People subscribed via source and target branches