Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 Jul 13, 2020
29a208e
Fix key code. Not what was proposed
kjpou1 Jul 13, 2020
64e8227
Add TryGetValue<TValue> and Set<TValue> as per proposal
kjpou1 Jul 14, 2020
23f0207
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Jul 14, 2020
b0e55ee
Add missing obsolete attribute
kjpou1 Jul 14, 2020
d22d482
Address review comments
kjpou1 Jul 14, 2020
4739203
Update tests to use Options and not obsolete Properties.
kjpou1 Jul 14, 2020
7101065
Implement IDictionary<string, object?> explicitly
kjpou1 Jul 15, 2020
1056cdc
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Jul 15, 2020
8886161
Update tests to use Options and not obsolete Properties.
kjpou1 Jul 15, 2020
f62bc16
Add HttpRequestOptions source to the System.Net.Http.Unit.Tests proje…
kjpou1 Jul 15, 2020
44929fd
Address review comments - explicit
kjpou1 Jul 15, 2020
478bca6
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Jul 15, 2020
8098c0e
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 Jul 16, 2020
3d5d7fa
Fix build error cannot convert from 'string' to 'System.Net.Http.Http…
kjpou1 Jul 16, 2020
7398927
Add tests for HttpRequestOptions
kjpou1 Jul 16, 2020
ea78e61
Fix test build
kjpou1 Jul 16, 2020
d6b49c5
Add special case code for NETFRAMEWORK for API change.
kjpou1 Jul 17, 2020
1b5683e
#endif out of place fix
kjpou1 Jul 17, 2020
23f1bc8
#endif out of place fix
kjpou1 Jul 17, 2020
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
Next Next commit
[browser][wasm] Initial addition of configuring request options in Br…
…owser WebAssembly
  • Loading branch information
kjpou1 committed Jul 13, 2020
commit f47ccd3f72d86a12dd823a2b698f037b4ec30a2e
10 changes: 10 additions & 0 deletions src/libraries/System.Net.Http/ref/System.Net.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,22 @@ public HttpRequestMessage(System.Net.Http.HttpMethod method, System.Uri? request
public System.Net.Http.Headers.HttpRequestHeaders Headers { get { throw null; } }
public System.Net.Http.HttpMethod Method { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object?> Properties { get { throw null; } }
public HttpRequestOptions Options { get { throw null; } }
public System.Uri? RequestUri { get { throw null; } set { } }
public System.Version Version { get { throw null; } set { } }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
public override string ToString() { throw null; }
}

public readonly struct HttpRequestOptionsKey<TKey>
{
public HttpRequestOptionsKey(TKey key) {}
public TKey Key { get { throw null; } }
}

public sealed class HttpRequestOptions : System.Collections.Generic.Dictionary<HttpRequestOptionsKey<string>, object> { }

public partial class HttpResponseMessage : System.IDisposable
{
public HttpResponseMessage() { }
Expand Down
4 changes: 3 additions & 1 deletion src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<AssemblyName>System.Net.Http</AssemblyName>
Expand Down Expand Up @@ -47,6 +47,8 @@
<Compile Include="System\Net\Http\HttpParseResult.cs" />
<Compile Include="System\Net\Http\HttpRequestException.cs" />
<Compile Include="System\Net\Http\HttpRequestMessage.cs" />
<Compile Include="System\Net\Http\HttpRequestOptions.cs" />
<Compile Include="System\Net\Http\HttpRequestOptionsKey.cs" />
<Compile Include="System\Net\Http\HttpResponseMessage.cs" />
<Compile Include="System\Net\Http\HttpRuleParser.cs" />
<Compile Include="System\Net\Http\HttpTelemetry.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected internal override async Task<HttpResponseMessage> SendAsync(HttpReques
{
var requestObject = new JSObject();

if (request.Properties.TryGetValue("WebAssemblyFetchOptions", out object? fetchOptionsValue) &&
if (request.Options.TryGetValue(new HttpRequestOptionsKey<string>("WebAssemblyFetchOptions"), out object? fetchOptionsValue) &&
fetchOptionsValue is IDictionary<string, object> fetchOptions)
{
foreach (KeyValuePair<string, object> item in fetchOptions)
Expand Down Expand Up @@ -221,7 +221,7 @@ protected internal override async Task<HttpResponseMessage> SendAsync(HttpReques

HttpResponseMessage httpResponse = new HttpResponseMessage((HttpStatusCode)status.Status);

bool streamingEnabled = request.Properties.TryGetValue("WebAssemblyEnableStreamingResponse", out object? streamingEnabledValue) && (bool)(streamingEnabledValue ?? false);
bool streamingEnabled = request.Options.TryGetValue(new HttpRequestOptionsKey<string>("WebAssemblyEnableStreamingResponse"), out object? streamingEnabledValue) && (bool)(streamingEnabledValue ?? false);

httpResponse.Content = StreamingSupported && streamingEnabled
? new StreamContent(wasmHttpReadStream = new WasmHttpReadStream(status))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class HttpRequestMessage : IDisposable
private HttpContent? _content;
private bool _disposed;
private IDictionary<string, object?>? _properties;
private HttpRequestOptions? _options;

public Version Version
{
Expand Down Expand Up @@ -111,6 +112,7 @@ public HttpRequestHeaders Headers

internal bool HasHeaders => _headers != null;

[Obsolete("Use Options instead.")]
public IDictionary<string, object?> Properties
{
get
Expand All @@ -123,6 +125,18 @@ public HttpRequestHeaders Headers
}
}

public HttpRequestOptions Options
{
get
{
if (_options == null)
{
_options = new HttpRequestOptions();
}
return _options;
}
}

public HttpRequestMessage()
: this(HttpMethod.Get, (Uri?)null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;

namespace System.Net.Http
{
public sealed class HttpRequestOptions : Dictionary<HttpRequestOptionsKey<string>, object?> { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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<TKey>
{
private readonly TKey _key;
public HttpRequestOptionsKey(TKey key)
{
_key = key;
}
public TKey Key => _key;
}
}