WSGI 字节范围服务

发布于 2024-07-14 00:30:07 字数 770 浏览 6 评论 0原文

我正在考虑在 WSGI 服务器/应用程序中支持 HTTP/1.1 字节服务

  • 恢复部分下载
  • 多部分下载
  • 更好的流式传输

WSGI PEP 333 提到 WSGI 服务器可以实现字节服务的处理(来自 RFC 2616 第 14.35 节。 2 定义了 Accept-Range/Range/Content-Range 响应/请求/响应头),如果声明了该功能,应用程序应该实现它:

服务器可以传输字节范围 应用程序的响应如果 应客户要求,以及 应用程序本身不支持 字节范围。 然而,再一次, 应用程序应该执行此操作 如果需要,可以自行运行。

我已经执行了一些谷歌搜索,但发现很少有关于哪些可用的 WSGI 服务器/中间件/应用程序实现字节范围的信息? 有谁在该领域有经验并且可以提示我进一步挖掘的地方吗?

编辑:任何人都可以发表评论,我如何增强问题才能找到答案?

I'm looking into supporting HTTP/1.1 Byte serving in WSGI server/application for:

  • resuming partial downloads
  • multi-part downloads
  • better streaming

WSGI PEP 333 mentions that WSGI server may implement handling of byte serving (from RFC 2616 section 14.35.2 defines Accept-Range/Range/Content-Range response/request/response headers) and application should implement it if announces the capability:

A server may transmit byte ranges of
the application's response if
requested by the client, and the
application doesn't natively support
byte ranges. Again, however, the
application should perform this
function on its own if desired.

I've performed some Googling but found little information upon which of the available WSGI servers/middleware/applications implement Byte-Ranges? Does anyone has an experience in the field and can hint me place to dig further?

EDIT: Can anyone comment, how I can enhance the question to be able to find an answer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅忆流年 2024-07-21 00:30:07

我认为 webob 可能会解决问题,请参阅 范围请求实现的文件示例,可有效地查找正在提供的文件。

I think webob may do the trick, see the end of the file example for a range request implementation which efficiently seeks into the file being served.

财迷小姐 2024-07-21 00:30:07

您只需使用 WebOb 并将响应创建为 Response(conditional_request=True)WebOb Response 对象的子类,使 conditional_request=True 成为默认值。

conditional_request=True 且请求要求提供范围时,WebOb 的 Response.app_iter_range 会包装完整的响应以仅返回请求的范围。

WebOb 文件服务示例展示了如何实现您自己的 app_iter_range 适用于在不生成整个响应的情况下获取一系列字节的实际情况。

You just need to use WebOb and create the response as Response(conditional_request=True) or subclass the WebOb Response object making conditional_request=True the default.

When conditional_request=True and the request asked for a range, WebOb's Response.app_iter_range wraps the complete response to return only the requested range.

The WebOb file serving example shows how you would implement your own app_iter_range for cases where it is practical to get a range of bytes without generating the whole response.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文