﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34989	Set Content-Length where possible for HttpResponses.	Jeppe Fihl-Pearson	Ronan LE HAY	"We upgraded from Django 4.1.13 to 4.2.7 this week, and as part of this, we noticed redirects for URLs that added a missing trailing slash took 4-5 seconds. Before the upgrade, the redirects only took a fraction of a second to return.

Debugging this, I've found out it's related to the change made for #33700. If I revert that change the delay goes away.

I've also found out this requires a slightly specific setup. So far I've only seen it when using uWSGI as the application server using the `http11-socket` option. I am not able to reproduce the issue when using `http-socket` for configuring the listening socket.

I have adapted the reproduction case from #33700 to show this issue. It can be found at https://github.com/Tenzer/django-slow-redirect. When making a request against the `http-socket` port, it returns immediately:
{{{
% time curl -si http://127.0.0.1:8010/url
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: /url/

curl -si http://127.0.0.1:8010/url  0.01s user 0.01s system 65% cpu 0.033 total
}}}
but when I make a request against the `http11-socket` port, it instead takes at least 4 seconds extra:
{{{
% time curl -si http://127.0.0.1:8011/url
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: /url/

curl -si http://127.0.0.1:8011/url  0.01s user 0.01s system 0% cpu 4.026 total
}}}

I am assuming this might be hitting a timeout somewhere but I can't work out where that might be or how the changes in https://github.com/django/django/pull/15689 might have caused it.

We have for now had to switch to using the `http-socket` option in uWSGI, but it would be ideal if the `http11-socket` option also would work, as that is required for uWSGI to support keep-alive."	Cleanup/optimization	assigned	HTTP handling	4.2	Normal		CommonMiddleware uWSGI	Florian Apolloner	Accepted	0	0	0	0	0	0
