-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser][wasm] Configuring request options in Browser WebAssembly #39182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f47ccd3
[browser][wasm] Initial addition of configuring request options in Br…
kjpou1 29a208e
Fix key code. Not what was proposed
kjpou1 64e8227
Add TryGetValue<TValue> and Set<TValue> as per proposal
kjpou1 23f0207
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 b0e55ee
Add missing obsolete attribute
kjpou1 d22d482
Address review comments
kjpou1 4739203
Update tests to use Options and not obsolete Properties.
kjpou1 7101065
Implement IDictionary<string, object?> explicitly
kjpou1 1056cdc
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 8886161
Update tests to use Options and not obsolete Properties.
kjpou1 f62bc16
Add HttpRequestOptions source to the System.Net.Http.Unit.Tests proje…
kjpou1 44929fd
Address review comments - explicit
kjpou1 478bca6
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 8098c0e
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 3d5d7fa
Fix build error cannot convert from 'string' to 'System.Net.Http.Http…
kjpou1 7398927
Add tests for HttpRequestOptions
kjpou1 ea78e61
Fix test build
kjpou1 d6b49c5
Add special case code for NETFRAMEWORK for API change.
kjpou1 1b5683e
#endif out of place fix
kjpou1 23f1bc8
#endif out of place fix
kjpou1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace System.Net.Http | ||
| { | ||
| public sealed class HttpRequestOptions : IDictionary<string, object?> | ||
kjpou1 marked this conversation as resolved.
Show resolved
Hide resolved
kjpou1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| private Dictionary<string, object?> Options { get; } = new Dictionary<string, object?>(); | ||
| object? IDictionary<string, object?>.this[string key] | ||
| { | ||
| get | ||
| { | ||
| return Options[key]; | ||
| } | ||
| set | ||
| { | ||
| Options[key] = value; | ||
| } | ||
| } | ||
| ICollection<string> IDictionary<string, object?>.Keys => Options.Keys; | ||
| ICollection<object?> IDictionary<string, object?>.Values => Options.Values; | ||
| int ICollection<KeyValuePair<string, object?>>.Count => Options.Count; | ||
| bool ICollection<KeyValuePair<string, object?>>.IsReadOnly => ((IDictionary<string, object?>)Options).IsReadOnly; | ||
| void IDictionary<string, object?>.Add(string key, object? value) => Options.Add(key, value); | ||
| void ICollection<KeyValuePair<string, object?>>.Add(KeyValuePair<string, object?> item) => ((IDictionary<string, object?>)Options).Add(item); | ||
| void ICollection<KeyValuePair<string, object?>>.Clear() => Options.Clear(); | ||
| bool ICollection<KeyValuePair<string, object?>>.Contains(KeyValuePair<string, object?> item) => ((IDictionary<string, object?>)Options).Contains(item); | ||
| bool IDictionary<string, object?>.ContainsKey(string key) => Options.ContainsKey(key); | ||
| void ICollection<KeyValuePair<string, object?>>.CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex) => | ||
| ((IDictionary<string, object?>)Options).CopyTo(array, arrayIndex); | ||
| IEnumerator<KeyValuePair<string, object?>> IEnumerable<KeyValuePair<string, object?>>.GetEnumerator() => Options.GetEnumerator(); | ||
| System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => ((System.Collections.IEnumerable)Options).GetEnumerator(); | ||
| bool IDictionary<string, object?>.Remove(string key) => Options.Remove(key); | ||
| bool ICollection<KeyValuePair<string, object?>>.Remove(KeyValuePair<string, object?> item) => ((IDictionary<string, object?>)Options).Remove(item); | ||
| bool IDictionary<string, object?>.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value); | ||
| public bool TryGetValue<TValue>(HttpRequestOptionsKey<TValue> key, [MaybeNullWhen(false)] out TValue value) | ||
| { | ||
| if (Options.TryGetValue(key.Key, out object? _value) && _value is TValue tvalue) | ||
| { | ||
| value = tvalue; | ||
| return true; | ||
| } | ||
|
|
||
| value = default(TValue); | ||
| return false; | ||
| } | ||
|
|
||
| public void Set<TValue>(HttpRequestOptionsKey<TValue> key, TValue value) | ||
| { | ||
| Options[key.Key] = value; | ||
| } | ||
| } | ||
| } | ||
kjpou1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
16 changes: 16 additions & 0 deletions
16
src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptionsKey.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
|
|
||
| namespace System.Net.Http | ||
| { | ||
| public readonly struct HttpRequestOptionsKey<TValue> | ||
| { | ||
| public string Key { get; } | ||
| public HttpRequestOptionsKey(string key) | ||
| { | ||
| Key = key; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.