Don't send header if it makes no sense to do so.

This commit is contained in:
Itamar Turner-Trauring 2022-02-10 13:57:57 -05:00
parent b049d4a792
commit 7466ee25a8

View File

@ -329,8 +329,11 @@ class HTTPServer(object):
data = bucket.read(offset, end - offset) data = bucket.read(offset, end - offset)
request.setResponseCode(http.PARTIAL_CONTENT) request.setResponseCode(http.PARTIAL_CONTENT)
request.setHeader( if len(data):
"content-range", # For empty bodies the content-range header makes no sense since
ContentRange("bytes", offset, offset + len(data)).to_header(), # the end of the range is inclusive.
) request.setHeader(
"content-range",
ContentRange("bytes", offset, offset + len(data)).to_header(),
)
return data return data