How do I use WebClient.DownloadFile
with digest authentication and a query string?
When I try to use it I get a 401 response.
This is the Apache error log:
[Tue Jun 24 17:31:49 2014] [error] [client x.x.x.x] Digest: uri mismatch - </file-1.php> does not match request-uri </file-1.php?since=1403587422>
Here is how I try to download the file:
Uri uri = new Uri("http://example.com/file-1.php?since=1403587422");
WebClient webClient = new WebClient();
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(
new Uri(uri.GetLeftPart(UriPartial.Authority)),
"Digest",
new NetworkCredential("username", "password")
);
webClient.Credentials = credentialCache;
webClient.DownloadFile(uri, file.OutputFile);