Skip to content

Commit

Permalink
Merge pull request #18546 from unoplatform/dev/spouliot/HttpRequestHe…
Browse files Browse the repository at this point in the history
…aderCollection

fix: add minimum API HttpRequestHeaderCollection to work
  • Loading branch information
spouliot authored Nov 14, 2024
2 parents e17cd40 + d910ed2 commit 5f62952
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ internal void OnOwnerApplyTemplate()
{
_nativeWebView = GetNativeWebViewFromTemplate();

//The nativate WebView already navigate to a blank page if no source is set.
//The native WebView already navigate to a blank page if no source is set.
//Avoid a bug where invoke GoBack() on WebView do nothing in Android 4.4
UpdateFromInternalSource();
OnScrollEnabledChanged(_scrollEnabled);
Expand Down Expand Up @@ -280,8 +280,16 @@ private void UpdateFromInternalSource()
{
_nativeWebView.ProcessNavigation(html);
}
else if (_processedSource is HttpRequestMessage httpRequestMessage)
else if (_processedSource is global::Windows.Web.Http.HttpRequestMessage requestMessage)
{
var httpRequestMessage = new HttpRequestMessage()
{
RequestUri = requestMessage.RequestUri
};
foreach (var header in requestMessage.Headers)
{
httpRequestMessage.Headers.Add(header.Key, header.Value);
}
_nativeWebView.ProcessNavigation(httpRequestMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public bool TryAppendWithoutValidation(string name, string value)
// Forced skipping of method Windows.Web.Http.Headers.HttpRequestHeaderCollection.First()
// Skipping already declared method Windows.Web.Http.Headers.HttpRequestHeaderCollection.ToString()
// Processing: System.Collections.Generic.IDictionary<string, string>
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
// DeclaringType: System.Collections.Generic.IDictionary<string, string>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Add(string key, string value)
Expand Down Expand Up @@ -228,7 +228,7 @@ public void Add(string key, string value)
}
#endif
// Processing: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
// DeclaringType: System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Add(global::System.Collections.Generic.KeyValuePair<string, string> item)
Expand All @@ -255,7 +255,7 @@ public void CopyTo(global::System.Collections.Generic.KeyValuePair<string, strin
// Skipping already implement System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>.Count
// Skipping already implement System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>.IsReadOnly
// Processing: System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>>
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
// DeclaringType: System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>>
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<string, string>> GetEnumerator()
Expand All @@ -264,7 +264,7 @@ public void CopyTo(global::System.Collections.Generic.KeyValuePair<string, strin
}
#endif
// Processing: System.Collections.IEnumerable
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
// DeclaringType: System.Collections.IEnumerable
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
Expand Down
16 changes: 16 additions & 0 deletions src/Uno.UWP/Web/Http/HttpRequestHeaderCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public DateTimeOffset? Date
}
}

public void Add(string key, string value)
=> _dictionary.Add(key, value);

public void Add(KeyValuePair<string, string> item)
=> Add(item.Key, item.Value);

public bool ContainsKey(string key)
=> _dictionary.ContainsKey(key);

Expand Down Expand Up @@ -214,4 +220,14 @@ public void Clear()
public int Count => _dictionary.Count;

public bool IsReadOnly => false;

public global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<string, string>> GetEnumerator()
{
return _dictionary.GetEnumerator();
}

global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return _dictionary.GetEnumerator();
}
}

0 comments on commit 5f62952

Please sign in to comment.