為什麼我的web瀏覽器有時無法顯示剩餘的下載時間?

有時,瀏覽器(或其他應用程式)上忠實的下載進度表只是舉手之勞,放棄顯示剩餘的下載時間。為什麼它有時會鎖定預計的下載時間,有時卻無法同時報告?...

為什麼我的web瀏覽器有時無法顯示剩餘的下載時間?

有時,瀏覽器(或其他應用程式)上忠實的下載進度表只是舉手之勞,放棄顯示剩餘的下載時間。為什麼它有時會鎖定預計的下載時間,有時卻無法同時報告?

今天的問答環節是由SuperUser提供的,SuperUser是Stack Exchange的一個分支,是一個由社群驅動的問答網站分組。

問題

超級使用者讀者Coldblackice想知道為什麼他的瀏覽器不總是會有汙點:

Occasionally, when downloading a file in a web browser, the download progress doesn’t “know” the total size of the file, or how far along in the download it is — it just shows the speed at which it’s downloading, with a total as “Unknown”.

Why wouldn’t the browser know the final size of some files? Where does it get this information in the first place?

到底在哪裡?

答案

超級使用者貢獻者Gronostaj提供了以下見解:

To request documents from web servers, browsers use the HTTP protocol. You may know that name from your address bar (it may be hidden now, but when you click the address bar, copy the URL and paste it in some text editor, you’ll see http:// at the beginning). It’s a simple text-based protocol and it works like this:

First, your browser connects to the website’s server and sends a URL of the document it wants to download (web pages are documents, too) and some details about the browser itself (User-Agent etc). For example, to load the main page on the SuperUser site, http://superuser.com/, my browser sends a request that looks like this:

GET / HTTP/1.1 Host: superuser.com Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) Accept-Encoding: gzip,deflate,sdch Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4 Cookie: [removed for security] DNT: 1 If-Modified-Since: Tue, 09 Jul 2013 07:14:17 GMT

The first line specifies which document the server should return. The other lines are called headers; they look like this:

Header name: Header value

These lines send additional information that helps the server decide what to do.

If all is well, the server will respond by sending the requested document. The resp***e starts off with a status message, followed by some headers (with details about the document) and finally, if all is well, the document’s content. This is what the SuperUser server’s reply for my request looks like:

HTTP/1.1 200 OK Cache-Control: public, max-age=60 Content-Type: text/html; charset=utf-8 Expires: Tue, 09 Jul 2013 07:27:20 GMT Last-Modified: Tue, 09 Jul 2013 07:26:20 GMT Vary: * X-Frame-Opti***: SAMEORIGIN Date: Tue, 09 Jul 2013 07:26:19 GMT Content-Length: 139672 <!DOCTYPE html> <html> [...snip...] </html>

After the last line, SuperUser’s server closes the connection.

The first line (HTTP/1.1 200 OK) contains the resp***e code, in this case it’s 200 OK. It means that the server will return a document, as requested. When the server doesn’t manage to do so, the code will be something else: you have probably seen 404 Not Found, and 403 Forbidden is quite common, too. Then the headers follow.

When the browser finds an empty line in the resp***e, it knows that everything past that line is the content of the document it requested. So in this case <!DOCTYPE html> is the first line of the SuperUser’s homepage code. If I was requesting a document to download, it would probably be some gibberish characters, because most document formats are unreadable without prior processing.

Back to headers. The most interesting one for us is the last one, Content-Length. It informs the browser how many bytes of data it should expect after the empty line, so basically it’s the document size expressed in bytes. This header isn’t mandatory and may be omitted by the server. Sometimes the document size can’t be predicted (for example when the document is generated on the fly), sometimes lazy programmers don’t include it (quite common on driver download sites), sometimes websites are created by newbies who don’t know of such a header.

Anyway, whatever the reason is, the header can be missing. In that case the browser doesn’t know how much data the server is going to send, and thus displays the document size as unknown, waiting for the server to close the connection. And that’s the reason for unknown document sizes.


有什麼要補充的解釋嗎?在評論中發出聲音。想從其他精通技術的Stack Exchange使用者那裡瞭解更多答案嗎?在這裡檢視完整的討論主題。

  • 發表於 2021-04-11 17:03
  • 閱讀 ( 37 )
  • 分類:網際網路

你可能感興趣的文章

最適合您的usb驅動器的5種行動式web瀏覽器

... 為什麼要使用行動式網路瀏覽器? ...

  • 發佈於 2021-03-19 06:33
  • 閲讀 ( 61 )

如何避免假廣告偽裝成假下載連結

...裝成下載按鈕的廣告是一個巨大的痛苦。讓我們看看它們為什麼存在,如何發現它們,以及如何避免廣告。 ...

  • 發佈於 2021-03-20 03:57
  • 閲讀 ( 60 )

9個讓網頁瀏覽更有趣的opera瀏覽器提示

... 這也是為什麼我們中的一些人認為它比谷歌的Chrome更好的原因之一。你可以從歌劇中得到更多的好處。 ...

  • 發佈於 2021-03-21 17:51
  • 閲讀 ( 49 )

safari下載不起作用?7故障排除提示和修復嘗試

...然後關閉你的Mac電腦,而它仍在進行中可以暫停。這就是為什麼在下載資料夾中找不到下載的原因:它實際上還沒有完成下載。 ...

  • 發佈於 2021-03-21 20:42
  • 閲讀 ( 45 )

如何使用curl從linux命令列下載檔案

...url的功能,以及何時應該使用它而不是wget。 curl和wget有什麼區別? 人們常常很難確定wget和curl命令的相對優勢。這些命令確實有一些功能重疊。它們各自可以從遠端位置檢索檔案,但這就是相似性的終點。 wget是下載內容和檔...

  • 發佈於 2021-04-02 22:46
  • 閲讀 ( 67 )

如何在Windows10中啟用剩餘電池時間

...不是時間。雖然它有它的怪癖,你可能還是想看看它。 為什麼微軟隱瞞了電池壽命的估計? 這些資訊被刪除了,因為這只是一個估計。它可能會發生巨大的變化,這取決於正在執行的程序、螢幕的亮度以及您是連線到Wi-Fi還是...

  • 發佈於 2021-04-03 18:39
  • 閲讀 ( 41 )

如何修復404找不到的錯誤

...很可能是你要找的頁面被移動或刪除了,所有者可以澄清為什麼要這樣做。如果沒有聯絡方式,你可以嘗試在他們的社交媒體**問該網站。

  • 發佈於 2021-04-05 23:05
  • 閲讀 ( 53 )

如何安全地將大檔案傳送給任何使用firefox send的人

... send上傳和共享檔案 開始是很簡單的。首先開啟任何現代瀏覽器:Firefox、Chrome、Safari和Edge在編寫本篇文章時都受支援,假設您的瀏覽器是最新的。然後前往send.firefox.com. 您可以單擊藍色框來選擇檔案,也可以從計算機的檔案管...

  • 發佈於 2021-04-07 09:13
  • 閲讀 ( 45 )

三種讓蒸汽更快的方法

...但這些資訊沒有那麼有用。 加速蒸汽和你的遊戲 相關:什麼是固態硬碟(SSD),我需要它嗎? 一種加速所有遊戲和Steam本身的方法是使用固態硬碟(SSD)並安裝Steam。Steam允許您將預設位於C:\Program Files(x86)\Steam的Steam資料夾移...

  • 發佈於 2021-04-07 14:30
  • 閲讀 ( 55 )

如何保護你的facebook帳戶

...不包含個人資訊,因為這些很容易被社會工程。 相關:為什麼你應該使用密碼管理器,以及如何開始 不過,最重要的是,不要在網際網路上的任何地方使用此密碼。您應該為您擁有的每個帳戶使用不同的密碼,理想情況下,它...

  • 發佈於 2021-04-08 10:40
  • 閲讀 ( 45 )
dajruvpiptehg
dajruvpiptehg

0 篇文章

作家榜

  1. admin 0 文章
  2. 孫小欽 0 文章
  3. JVhby0 0 文章
  4. fvpvzrr 0 文章
  5. 0sus8kksc 0 文章
  6. zsfn1903 0 文章
  7. w91395898 0 文章
  8. SuperQueen123 0 文章

相關推薦