@joebigelow / wix / commits / 77504042

Ignore HEAD request failure in dlutil's DownloadUrl.

Fixes #6331

Sean Hall committed Feb 18, 2022 at 17:41 UTC 7750404222a7c5bb6543dd246c2cce0f7c097d8d
4 files changed +30 -4
src/libs/dutil/WixToolset.DUtil/dlutil.cpp
+4 -1
@@ -158,7 +158,10 @@ extern "C" HRESULT DAPI DownloadUrl(
158
159 // Get the resource size and creation time from the internet.
160 hr = GetResourceMetadata(hSession, &sczUrl, pDownloadSource->sczUser, pDownloadSource->sczPassword, pAuthenticate, &dw64Size, &ftCreated);
161 - DlExitOnFailure(hr, "Failed to get size and time for URL: %ls", sczUrl);
161 + if (FAILED(hr))
162 + {
163 + LogStringLine(REPORT_VERBOSE, "Ignoring failure to get size and time for URL: %ls (error 0x%x)", sczUrl, hr);
164 + }
165
166 // Ignore failure to initialize resume because we will fall back to full download then
167 // download.
src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
+4 -1
@@ -67,6 +67,7 @@ namespace WixToolsetTest.BurnE2E
67 { "/BundleA/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") },
68 { "/BundleA/PackageB.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageB.msi") },
69 });
70 + webServer.DisableHeadResponses = true;
71 webServer.Start();
72
73 // Don't install PackageB initially so it will be installed when run from the package cache.
@@ -95,11 +96,13 @@ namespace WixToolsetTest.BurnE2E
96
97 testBAController.SetPackageRequestedState("PackageB", RequestState.Present);
98
98 - bundleA.Modify(bundlePackageCachePath);
99 + var modifyLogPath = bundleA.Modify(bundlePackageCachePath);
100 bundleA.VerifyRegisteredAndInPackageCache();
101
102 packageA.VerifyInstalled(true);
103 packageB.VerifyInstalled(true);
104 +
105 + Assert.True(LogVerifier.MessageInLogFile(modifyLogPath, "Ignoring failure to get size and time for URL: http://localhost:9999/e2e/BundleA/PackageB.msi (error 0x80070002)"));
106 }
107
108 [Fact]
src/test/burn/WixToolsetTest.BurnE2E/IWebServer.cs
+2
@@ -7,6 +7,8 @@ namespace WixToolsetTest.BurnE2E
7
8 public interface IWebServer : IDisposable
9 {
10 + bool DisableHeadResponses { get; set; }
11 +
12 /// <summary>
13 /// Registers a collection of relative URLs (the key) with its absolute path to the file (the value).
14 /// </summary>
src/test/burn/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs
+20 -2
@@ -7,6 +7,7 @@ namespace WixToolsetTest.BurnE2E
7 using System.IO;
8 using Microsoft.AspNetCore.Builder;
9 using Microsoft.AspNetCore.Hosting;
10 + using Microsoft.AspNetCore.StaticFiles;
11 using Microsoft.Extensions.FileProviders;
12 using Microsoft.Extensions.FileProviders.Physical;
13 using Microsoft.Extensions.Hosting;
@@ -18,6 +19,8 @@ namespace WixToolsetTest.BurnE2E
19
20 private IHost WebHost { get; set; }
21
22 + public bool DisableHeadResponses { get; set; }
23 +
24 public void AddFiles(Dictionary<string, string> physicalPathsByRelativeUrl)
25 {
26 foreach (var kvp in physicalPathsByRelativeUrl)
@@ -40,6 +43,7 @@ namespace WixToolsetTest.BurnE2E
43 FileProvider = this,
44 RequestPath = "/e2e",
45 ServeUnknownFileTypes = true,
46 + OnPrepareResponse = this.OnPrepareStaticFileResponse,
47 });
48 });
49 })
@@ -47,13 +51,24 @@ namespace WixToolsetTest.BurnE2E
51 this.WebHost.Start();
52 }
53
54 + private void OnPrepareStaticFileResponse(StaticFileResponseContext obj)
55 + {
56 + if (this.DisableHeadResponses && obj.Context.Request.Method == "HEAD")
57 + {
58 + obj.Context.Response.StatusCode = 404;
59 + }
60 + }
61 +
62 public void Dispose()
63 {
64 var waitTime = TimeSpan.FromSeconds(5);
65 this.WebHost?.StopAsync(waitTime).Wait(waitTime);
66 }
67
56 - public IDirectoryContents GetDirectoryContents(string subpath) => throw new NotImplementedException();
68 + public IDirectoryContents GetDirectoryContents(string subpath)
69 + {
70 + throw new NotImplementedException();
71 + }
72
73 public IFileInfo GetFileInfo(string subpath)
74 {
@@ -65,6 +80,9 @@ namespace WixToolsetTest.BurnE2E
80 return new NotFoundFileInfo(subpath);
81 }
82
68 - public IChangeToken Watch(string filter) => throw new NotImplementedException();
83 + public IChangeToken Watch(string filter)
84 + {
85 + throw new NotImplementedException();
86 + }
87 }
88 }
\ No newline at end of file