Skip to content

Commit

Permalink
Provoke AWS into sending Content-Length header
Browse files Browse the repository at this point in the history
head used to get content lengths, but does not any more, unless
Accept-Encoding is unset, presumably because compressed files might
have different lengths (unsure if a requests or AWS change)
  • Loading branch information
dragon-dxw committed Apr 6, 2023
1 parent 5931694 commit fd6c9ef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion judgments/views/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def detail_xml(_request, judgment_uri):

def get_pdf_size(judgment_uri):
"""Return the size of the S3 PDF for a judgment as a string in brackets, or an empty string if unavailable"""
response = requests.head(get_pdf_uri(judgment_uri))
response = requests.head(
get_pdf_uri(judgment_uri), headers={"Accept-Encoding": None}
)
content_length = response.headers.get("Content-Length", None)
if content_length:
filesize = filesizeformat(int(content_length))
Expand Down

0 comments on commit fd6c9ef

Please sign in to comment.