获取正确的 HTTP 范围,以便“将其全部删除”

发布于 2024-10-18 04:06:31 字数 6617 浏览 8 评论 0原文

我构建了一个网络应用程序,该应用程序应该提供录制电视的下载服务(对于那些大声喊出这是非法的人,我可以告诉他们:在德国,如果你做得对的话,这不是非法的)。您可以在 http://niklasfi.de:8080 查看该项目。

现在关于我的问题:下载+恢复适用于普通的 Firefox。但我在使用某些下载管理器时遇到了问题。所以我想知道为什么。我认为这与我的 HTTP 错误或其他问题有关。

当客户端想要下载某些内容时,首先会获得一个票证(在我们的示例中为 45729410)并重定向到实际的下载链接。

GET /createTicketFor/Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://niklasfi.de:8080/

HTTP/1.1 302 Moved Temporarily
location: /download/45729410
Connection: keep-alive
Transfer-Encoding: chunked

之后,firefox 向下载链接发送一个 get 请求(这是在您提供下载选项(打开方式、下载、downThaOneClick)时完成的)

GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://niklasfi.de:8080/

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: keep-alive

我选择了后者,因此将它们全部下载开始 4 个下载:

=== DTA.1 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, application/metalink4+xml;q=0.9,application/metalink+xml;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://niklasfi.de:8080/
Want-Digest: SHA512;q=0.9, SHA256;q=0.7, SHA, SHA1;q=0.5, MD5;q=0.3
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: close

=== DTA.2 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=714610068-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 714610068-1428013573/1428013574
Connection: close

=== DTA.3 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=357908315-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 357908315-1428013573/1428013574
Connection: close

=== DTA.4 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=1071311822-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 1071311822-1428013573/1428013574
Connection: close

让我想知道的是所有请求的范围标头都不会提供所需的信息,因为它“知道”必须在哪里启动其他三个请求,

但 DTA 取消了最后 3 个请求。 这是为什么?

这还不错,因为我们仍然可以暂停下载,这正是我想要的,现在我可以单击“暂停”按钮来执行以下操作。发送了两个请求:

=== RESTART ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=10909760-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 10909760-1428013573/1428013574
Connection: close

=== RESTART +1 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, application/metalink4+xml;q=0.9,application/metalink+xml;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://niklasfi.de:8080/
Want-Digest: SHA512;q=0.9, SHA256;q=0.7, SHA, SHA1;q=0.5, MD5;q=0.3
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: close

但是没有!突然整个下载被截断,我什至无法再暂停下载,而且我仍然只使用一个下载“线程”

。如果您发布任何解释此行为的想法,我们将很高兴。 (无论如何,感谢您阅读到这里)

I built web app which is supposed to serve Recorded TV as a download (For the folks yelling out that that is illegal, I can tell them: in Germany it isn't, if you do it right). You can have a look at the project at http://niklasfi.de:8080.

Now about my problem: Download + Resume works with plain firefox. But i am experiencing problems with some download managers. So I am wondering why. I think this has to do with me getting the HTTP wrong or something.

When a client wants to download something, it is first given a Ticket (In our case this is 45729410) and redirected to the actual download link.

GET /createTicketFor/Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://niklasfi.de:8080/

HTTP/1.1 302 Moved Temporarily
location: /download/45729410
Connection: keep-alive
Transfer-Encoding: chunked

Afterwards firefox sends a get request to the download link (this is done while you are provieded with the download options (open with, download, downThaOneClick)

GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://niklasfi.de:8080/

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: keep-alive

I chose the latter, so Down them All starts 4 downloads:

=== DTA.1 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, application/metalink4+xml;q=0.9,application/metalink+xml;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://niklasfi.de:8080/
Want-Digest: SHA512;q=0.9, SHA256;q=0.7, SHA, SHA1;q=0.5, MD5;q=0.3
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: close

=== DTA.2 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=714610068-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 714610068-1428013573/1428013574
Connection: close

=== DTA.3 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=357908315-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 357908315-1428013573/1428013574
Connection: close

=== DTA.4 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=1071311822-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 1071311822-1428013573/1428013574
Connection: close

What makes me wonder is that the Range headers of all requests do not give an end-point. DTA shoule have the inforation needed since it "knows" where it has to start the other three requests.

So far so good. Everything worked. But no! DTA cancels the last 3 requests. Why is that?

This is not too bad since one can still pause the Download which is what I want. In fact lets do that now. I click the "Pause" button. On resume the following two requests are sent:

=== RESTART ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Range: bytes=10909760-
Referer: http://niklasfi.de:8080/
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Content-Range: bytes 10909760-1428013573/1428013574
Connection: close

=== RESTART +1 ===
GET /download/45729410 HTTP/1.1
Host: niklasfi.de:8080
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0b12pre) Gecko/20110216 Firefox/4.0b12pre
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, application/metalink4+xml;q=0.9,application/metalink+xml;q=0.8
Accept-Language: de-de,de;q=0.8,en;q=0.7,en-gb;q=0.5,en-au;q=0.3,en-us;q=0.2
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Referer: http://niklasfi.de:8080/
Want-Digest: SHA512;q=0.9, SHA256;q=0.7, SHA, SHA1;q=0.5, MD5;q=0.3
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=Matrix_Revolutions_11.02.13_22-30_pro7_155_TVOON_DE.mpg.avi.otrkey
Content-Length: 1428013574
Connection: close

But no! Suddenly the whole download up until here is truncated and I can not even pause my download any more. The only option I have is to cancel it. And I still only uses one download "thread".

I would be glad if you posted any Ideas explaining this behaviour.
(Thanks for reading this far anyway)

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

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

发布评论

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

评论(1

浸婚纱 2024-10-25 04:06:31

如果提供“部分内容”,则必须发送 206 作为响应,而不是 200

instead of 200, 206 has to be sent as a response if 'Partial Content' is provided

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