Wie kommt man an eine "gute" cab?
Im Prinzip ist es möglich, eine bestimmte Version einer Datei herunterzuladen, indem man den "ETag" angibt. Das ist eine eindeutige Kennzeichnung der Datei, oft ein Hash oder eine UUID. Dazu muss man diesen ETag erst einmal abfragen:
- Code: Select all
~/Downloads$ wget --spider --server-response http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Spider-Modus eingeschaltet. Prüfe ob die Datei auf dem Server existiert.
--2016-07-15 16:25:15-- http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Auflösen des Hostnamen »download.windowsupdate.com (download.windowsupdate.com)«... 8.253.81.126, 8.253.81.78, 8.253.81.94, ...
Verbindungsaufbau zu download.windowsupdate.com (download.windowsupdate.com)|8.253.81.126|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort...
HTTP/1.1 200 OK
Date: Fri, 15 Jul 2016 14:25:08 GMT
Content-Type: application/octet-stream
Content-Length: 178327820
Connection: keep-alive
Cache-Control: max-age=0
Pragma: no-cache
ETag: "0a4bbc34adcd11:0"
Last-Modified: Tue, 12 Jul 2016 14:36:24 GMT
Server: Microsoft-IIS/8.5
x-ccc: DE
x-cid: 3
X-Powered-By: ASP.NET,ASP.NET
MSRegion: EMEA
Expires: Fri, 15 Jul 2016 14:25:08 GMT
Age: 0
Accept-Ranges: bytes
Länge: 178327820 (170M) [application/octet-stream]
Datei auf dem Server existiert.
Dann kann man diesen ETag benutzen, um einen zusätzlichen Header "If-Match" zu konstruieren. Die Optionen "--no-cache --no-dns-cache" können helfen, aber die Option "--no-dns-cache" gilt nur für wget; wenn das Betriebssystem oder der Router die Namensauflösung speichert, hat wget darauf keinen Einfluss:
- Code: Select all
~/Downloads$ wget --debug --no-cache --no-dns-cache --header='If-Match: "0a4bbc34adcd11:0"' http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Setting --cache (cache) to 0
Setting --dns-cache (dnscache) to 0
Setting --header (header) to If-Match: "0a4bbc34adcd11:0"
DEBUG output created by Wget 1.13.4 on linux-gnu.
URI encoding = »UTF-8«
--2016-07-15 18:00:44-- http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Auflösen des Hostnamen »download.windowsupdate.com (download.windowsupdate.com)«... 62.156.209.114, 62.156.209.112, 62.156.209.115, ...
Verbindungsaufbau zu download.windowsupdate.com (download.windowsupdate.com)|62.156.209.114|:80... verbunden.
Created socket 3.
Releasing 0x082e00d0 (new refcount 0).
Deleting unused 0x082e00d0.
---request begin---
GET /microsoftupdate/v6/wsusscan/wsusscn2.cab HTTP/1.1
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
User-Agent: Wget/1.13.4 (linux-gnu)
Accept: */*
Host: download.windowsupdate.com
Connection: Keep-Alive
If-Match: "0a4bbc34adcd11:0"
---request end---
HTTP-Anforderung gesendet, warte auf Antwort...
---response begin---
HTTP/1.1 200 OK
Pragma: no-cache
Content-Type: application/octet-stream
Accept-Ranges: bytes
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Last-Modified: Tue, 12 Jul 2016 14:36:24 GMT
ETag: "0a4bbc34adcd11:0"
Content-Length: 178327820
Date: Fri, 15 Jul 2016 16:00:37 GMT
Connection: keep-alive
X-CCC: DE
X-CID: 2
Cache-Control: max-age=0
---response end---
200 OK
Registered socket 3 for persistent reuse.
Länge: 178327820 (170M) [application/octet-stream]
In »»wsusscn2.cab.5«« speichern.
100%[======================================>] 178.327.820 677K/s in 4m 48s
2016-07-15 18:05:33 (604 KB/s) - »»wsusscn2.cab.5«« gespeichert [178327820/178327820]
Wenn man dagegen einen
falschen ETag angibt, bekommt man die Fehlermeldung "412 Precondition Failed" und eine eigene Fehlerseite. Dieselbe Antwort würde man erwarten, wenn der Server eine falsche Version der Datei anbietet:
- Code: Select all
~/Downloads$ wget --debug --no-cache --no-dns-cache --header='If-Match: "0a4bbc34adcdxx:0"' http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Setting --cache (cache) to 0
Setting --dns-cache (dnscache) to 0
Setting --header (header) to If-Match: "0a4bbc34adcdxx:0"
DEBUG output created by Wget 1.13.4 on linux-gnu.
URI encoding = »UTF-8«
--2016-07-15 17:59:55-- http://download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab
Auflösen des Hostnamen »download.windowsupdate.com (download.windowsupdate.com)«... 62.156.209.114, 62.156.209.115, 2a02:26f0:ce::216:9042, ...
Verbindungsaufbau zu download.windowsupdate.com (download.windowsupdate.com)|62.156.209.114|:80... verbunden.
Created socket 3.
Releasing 0x090fe0d0 (new refcount 0).
Deleting unused 0x090fe0d0.
---request begin---
GET /microsoftupdate/v6/wsusscan/wsusscn2.cab HTTP/1.1
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
User-Agent: Wget/1.13.4 (linux-gnu)
Accept: */*
Host: download.windowsupdate.com
Connection: Keep-Alive
If-Match: "0a4bbc34adcdxx:0"
---request end---
HTTP-Anforderung gesendet, warte auf Antwort...
---response begin---
HTTP/1.1 412 Precondition Failed
Pragma: no-cache
Content-Length: 1505
Content-Type: text/html
Last-Modified: Tue, 12 Jul 2016 14:36:24 GMT
Accept-Ranges: bytes
ETag: "0a4bbc34adcd11:0"
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
X-Powered-By: ARR/2.5
X-Powered-By: ASP.NET
Date: Fri, 15 Jul 2016 15:59:48 GMT
Connection: keep-alive
X-CCC: DE
X-CID: 2
Cache-Control: max-age=0
---response end---
412 Precondition Failed
Registered socket 3 for persistent reuse.
Skipping 1505 bytes of body: [<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>412 - Precondition set by the client failed when evaluated on the Web server.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-sSkipping 993 bytes of body: [ize:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="contentSkipping 481 bytes of body: [">
<div class="content-container"><fieldset>
<h2>412 - Precondition set by the client failed when evaluated on the Web server.</h2>
<h3>The request was not completed due to preconditions that are set in the request header. Preconditions prevent the requested method from being applied to a resource other than the one intended. An example of a precondition is testing for expired content in the page cache of the client.</h3>
</fieldset></div>
</div>
</body>
</html>
] done.
2016-07-15 17:59:56 FEHLER 412: Precondition Failed.
Insgesamt kann man auf diese Weise vier zusätzliche Header konstruieren:
- If-Match
- If-Unmodified-Since
- If-None-Match
- If-Modified-Since
Dabei kann man diese Header in zwei Gruppen einteilen:
- Der ersten beiden Header kann man zusammen verwenden, wenn man genau dieselbe Version noch einmal herunterladen will.
- Die letzten beiden Header kann man zusammen verwenden, wenn man eine neue Version der Datei herunterladen will.
Referenzen:
https://en.wikipedia.org/wiki/HTTP_ETagConcerning Etags and Datestamps
http://iwaw.europarchive.org/04/Clausen.pdfViele Grüße,
Hartmut