Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ public static bool TryExecute(this RoutedCommand command, object parameter, IInp
public static T GetOptionalTemplateChild<T>(Control templateParent, string childName) where T : FrameworkElement
{
ArgumentNullException.ThrowIfNull(templateParent);

ArgumentException.ThrowIfNullOrEmpty(childName);

object templatePart = templateParent.Template.FindName(childName, templateParent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,15 +578,15 @@ protected override void ProcessRecord()
// Disable writing to the OutFile.
OutFile = null;
}

// Detect insecure redirection
if (!AllowInsecureRedirect && response.RequestMessage.RequestUri.Scheme == "https" && response.Headers.Location?.Scheme == "http")
{
ErrorRecord er = new(new InvalidOperationException(), "InsecureRedirection", ErrorCategory.InvalidOperation, request);
er.ErrorDetails = new ErrorDetails(WebCmdletStrings.InsecureRedirection);
ThrowTerminatingError(er);
}

if (ShouldCheckHttpStatus && !_isSuccess)
{
string message = string.Format(
Expand Down Expand Up @@ -928,7 +928,7 @@ internal virtual void PrepareSession()
// We silently ignore header if value is null.
if (value is not null)
{
// Add the header value (or overwrite it if already present)
// Add the header value (or overwrite it if already present).
WebSession.Headers[key] = value.ToString();
}
}
Expand All @@ -942,7 +942,7 @@ internal virtual void PrepareSession()
WebSession.RetryIntervalInSeconds = RetryIntervalSec;
}
}

internal virtual HttpClient GetHttpClient(bool handleRedirect)
{
HttpClientHandler handler = new();
Expand Down Expand Up @@ -1286,7 +1286,7 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM
requestWithoutRange.Version,
requestWithoutRange.Method,
requestContentLength);

WriteVerbose(reqVerboseMsg);

response.Dispose();
Expand All @@ -1303,9 +1303,9 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM

// If the status code is 429 get the retry interval from the Headers.
// Ignore broken header and its value.
if (response.StatusCode is HttpStatusCode.Conflict && response.Headers.TryGetValues(HttpKnownHeaderNames.RetryAfter, out IEnumerable<string> retryAfter))
if (response.StatusCode is HttpStatusCode.Conflict && response.Headers.TryGetValues(HttpKnownHeaderNames.RetryAfter, out IEnumerable<string> retryAfter))
{
try
try
{
IEnumerator<string> enumerator = retryAfter.GetEnumerator();
if (enumerator.MoveNext())
Expand All @@ -1318,7 +1318,7 @@ internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestM
// Ignore broken header.
}
}

string retryMessage = string.Format(
CultureInfo.CurrentCulture,
WebCmdletStrings.RetryVerboseMsg,
Expand Down Expand Up @@ -1388,7 +1388,7 @@ private static Uri CheckProtocol(Uri uri)
}

private string QualifyFilePath(string path) => PathUtils.ResolveFilePath(filePath: path, command: this, isLiteralPath: true);

private static string FormatDictionary(IDictionary content)
{
ArgumentNullException.ThrowIfNull(content);
Expand Down Expand Up @@ -1485,7 +1485,7 @@ internal void SetRequestContent(HttpRequestMessage request, string content)
{
ArgumentNullException.ThrowIfNull(request);
ArgumentNullException.ThrowIfNull(content);

Encoding encoding = null;
if (ContentType is not null)
{
Expand Down Expand Up @@ -1565,7 +1565,7 @@ internal void SetRequestContent(HttpRequestMessage request, MultipartFormDataCon
{
ArgumentNullException.ThrowIfNull(request);
ArgumentNullException.ThrowIfNull(multipartContent);

// Content headers will be set by MultipartFormDataContent which will throw unless we clear them first
WebSession.ContentHeaders.Clear();

Expand Down Expand Up @@ -1735,7 +1735,8 @@ private static string FormatErrorMessage(string error, string contentType)
XmlDocument doc = new();
doc.LoadXml(error);

XmlWriterSettings settings = new XmlWriterSettings {
XmlWriterSettings settings = new XmlWriterSettings
{
Indent = true,
NewLineOnAttributes = true,
OmitXmlDeclaration = true
Expand Down