From 1d4cc5dcf8e702d67f15e311dacfa0f3fdbf0aaf Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 9 Sep 2021 20:32:29 +0200 Subject: [PATCH] missing doc for HttpRequestOptions, HttpRequestOptionsKey and HttpRequestMessage.Options --- .../src/System/Net/Http/HttpRequestMessage.cs | 3 +++ .../src/System/Net/Http/HttpRequestOptions.cs | 24 ++++++++++++++++++- .../System/Net/Http/HttpRequestOptionsKey.cs | 12 ++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs index 33e5b2527e1d54..6c71b4c08633f1 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestMessage.cs @@ -115,6 +115,9 @@ public Uri? RequestUri [Obsolete("HttpRequestMessage.Properties has been deprecated. Use Options instead.")] public IDictionary Properties => Options; + /// + /// Gets the collection of options to configure the HTTP request. + /// public HttpRequestOptions Options => _options ??= new HttpRequestOptions(); public HttpRequestMessage() diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs index 195eb0d10fe621..20116559c89303 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptions.cs @@ -6,6 +6,9 @@ namespace System.Net.Http { + /// + /// Represents a collection of options for an HTTP request. + /// public sealed class HttpRequestOptions : IDictionary { private Dictionary Options { get; } = new Dictionary(); @@ -36,6 +39,19 @@ public sealed class HttpRequestOptions : IDictionary bool IDictionary.Remove(string key) => Options.Remove(key); bool ICollection>.Remove(KeyValuePair item) => ((IDictionary)Options).Remove(item); bool IDictionary.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value); + + /// + /// Initializes a new instance of the HttpRequestOptions class. + /// + public HttpRequestOptions() { } + + /// + /// Gets the value of a given HTTP request option. + /// + /// Strongly typed key to get the value of HTTP request option. For example new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse") + /// Returns the value of HTTP request option. + /// The type of the HTTP value as defined by key parameter. + /// True, if an option is retrieved. public bool TryGetValue(HttpRequestOptionsKey key, [MaybeNullWhen(false)] out TValue value) { if (Options.TryGetValue(key.Key, out object? _value) && _value is TValue tvalue) @@ -48,9 +64,15 @@ public bool TryGetValue(HttpRequestOptionsKey key, [MaybeNullWhe return false; } + /// + /// Sets the value of a given request option. + /// + /// Strongly typed key to get the value of HTTP request option. For example new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse") + /// The value of the HTTP request option. + /// The type of the HTTP value as defined by key parameter. public void Set(HttpRequestOptionsKey key, TValue value) { Options[key.Key] = value; } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptionsKey.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptionsKey.cs index f51f8ebf162fe7..4c45c4738606d3 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptionsKey.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRequestOptionsKey.cs @@ -5,9 +5,21 @@ namespace System.Net.Http { + /// + /// Represents a key in the options for an HTTP request. + /// + /// The type of the value of the option. public readonly struct HttpRequestOptionsKey { + /// + /// Gets the name of the option. + /// public string Key { get; } + + /// + /// Initializes a new instance of the HttpRequestOptionsKey using the supplied key name. + /// + /// Name of the HTTP request option. public HttpRequestOptionsKey(string key) { Key = key;