Skip to content

Fixed streaming: removed Connection and Keep-Alive headers#700

Merged
AlexxIT merged 3 commits intoAlexxIT:masterfrom
Laxilef:patch-3
Sep 19, 2025
Merged

Fixed streaming: removed Connection and Keep-Alive headers#700
AlexxIT merged 3 commits intoAlexxIT:masterfrom
Laxilef:patch-3

Conversation

@Laxilef
Copy link
Copy Markdown
Contributor

@Laxilef Laxilef commented Sep 17, 2025

Исправляет #637
Пояснение: мы не должны прозрачно проксировать заголовки Connection и Keep-Alive, т.к. они должны соответствовать соответствующим параметрам сервера. response.force_close() используется намеренно, дабы клиенты не ждали новых данных, если произошел выход из цикла чтения раньше, чем запрошенные данные были прочитаны:

if not data or len(data) == 0:
    break

P.S. Т.к. добавил фильтрацию, то вырезал некоторые служебные заголовки яндекса, пользы от них нет.

@AlexxIT
Copy link
Copy Markdown
Owner

AlexxIT commented Sep 18, 2025

Спасибо! Хорошая идея. Добавил пару замечаний к коду.

@Laxilef
Copy link
Copy Markdown
Contributor Author

Laxilef commented Sep 18, 2025

Второй день тестирую, пока ни одного зависания воспроизведения на хромкаст устройствах. Можно дополнительно попросить потестировать в issue #637.

response.headers["Access-Control-Allow-Headers"] = "*"
response.headers["Access-Control-Allow-Origin"] = "*"

response.force_close()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это откуда и зачем?

Copy link
Copy Markdown
Contributor Author

@Laxilef Laxilef Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отключает Keep-Alive и в заголовках клиенту передается Connection: close

@AlexxIT AlexxIT merged commit 602ebde into AlexxIT:master Sep 19, 2025
2 checks passed
@AlexxIT
Copy link
Copy Markdown
Owner

AlexxIT commented Sep 19, 2025

Спасибо. Я оставил ваши идеи, но многое переписал.

@AlexxIT
Copy link
Copy Markdown
Owner

AlexxIT commented Sep 19, 2025

@Laxilef
Copy link
Copy Markdown
Contributor Author

Laxilef commented Sep 19, 2025

Date, Last-Modified, Etag можно оставить для работы браузерного кэша.
Глянул еще код, для корректной работы CORS (Access-Control-Allow-Origin и всё такое) необходимо еще отвечать на OPTIONS запросы, документация.

@Laxilef Laxilef deleted the patch-3 branch September 20, 2025 01:47
@AlexxIT
Copy link
Copy Markdown
Owner

AlexxIT commented Sep 20, 2025

Я думал про них. Но запросить одинокую ссылку невозможно, там jwt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants