mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-16 19:00:54 +00:00
Set Content-Length for HEAD requests
This commit is contained in:
parent
b93842b10c
commit
4a0bcde7a3
3 changed files with 8 additions and 6 deletions
|
@ -121,6 +121,9 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||
|
||||
def _handle_request(self, environ: types.WSGIEnviron
|
||||
) -> _IntermediateResponse:
|
||||
time_begin = datetime.datetime.now()
|
||||
request_method = environ["REQUEST_METHOD"].upper()
|
||||
|
||||
"""Manage a request."""
|
||||
def response(status: int, headers: types.WSGIResponseHeaders,
|
||||
answer: Union[None, str, bytes]) -> _IntermediateResponse:
|
||||
|
@ -144,7 +147,8 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||
headers["Content-Encoding"] = "gzip"
|
||||
|
||||
headers["Content-Length"] = str(len(answer))
|
||||
answers.append(answer)
|
||||
if request_method != "HEAD":
|
||||
answers.append(answer)
|
||||
|
||||
# Add extra headers set in configuration
|
||||
headers.update(self._extra_headers)
|
||||
|
@ -161,8 +165,6 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||
# Return response content
|
||||
return status_text, list(headers.items()), answers
|
||||
|
||||
time_begin = datetime.datetime.now()
|
||||
request_method = environ["REQUEST_METHOD"].upper()
|
||||
unsafe_path = environ.get("PATH_INFO", "")
|
||||
remote_host = "unknown"
|
||||
if environ.get("REMOTE_HOST"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue