Skip to content

Commit

Permalink
Fix etag comparison bug in FileResponseMixin and
Browse files Browse the repository at this point in the history
BaseFiles
  • Loading branch information
abersheeran committed Nov 28, 2023
1 parent e47d25b commit 691b8b6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion baize/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def generate_common_headers(
headers: Dict[str, str] = {
"accept-ranges": "bytes",
"last-modified": formatdate(stat_result.st_mtime, usegmt=True),
"etag": self.generate_etag(stat_result),
"etag": f'"{self.generate_etag(stat_result)}"',
}
if download_name or content_type == "application/octet-stream":
download_name = download_name or os.path.basename(filepath)
Expand Down
2 changes: 1 addition & 1 deletion baize/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def if_none_match(self, etag: str, if_none_match: str) -> bool:
if if_none_match.startswith("W/"):
if_none_match = if_none_match[2:]

return any(etag == i.strip() for i in if_none_match.split(","))
return any(etag == i.strip().strip('"') for i in if_none_match.split(","))

def if_modified_since(self, last_modified: float, if_modified_since: str) -> bool:
try:
Expand Down

0 comments on commit 691b8b6

Please sign in to comment.