Closed DmitriyYukhanov closed 1 year ago
All IDownloader
-derived downloaders now expose credentials as ICredentials
.
Also, all WebRequests created by the downloaders now have PreAuthenticated flag set.
For the sake of completeness, I introduced PreAuthenticatedWebClient
class that always returns a PreAuthenticated WebRequest.
This will be released with the next version!
Hey, I'd like to propose 2 improvements into how Credentials are handled right now:
Use
ICredentials
instead ofNetworkCredential
. It would allow passing theCredentialCache
which may be required in some cases, for example.Optionally, allow sending
Credentials
with request right away.By default,
Credentials
will send only after server return401
status code.But it's often a good idea to reduce bandwidth and requests count when dealing with CDNs which do require auth, so it's preferable to send the
Credentials
with the initial request instead.It's possible to achieve by extending
WebClient
(if you will not switch toHttpClient
) and settingWebRequest.PreAuthenticate
toTrue
, like it's shown in this Microsoft Learn example.Alternatively, it's possible to do this with manually constructing and adding the
HttpRequestHeader.Authorization
header from theCredentials
right to the initial request. This will be possible after #59 implementation, but still would be nice to just have an option to do this, like:and allow it to do all the rest under the hood.