Skip to content

Commit 646f452

Browse files
dougbuPranav Krishnamoorthypranavkmdotnet-bot
authored
Merge tag 'v3.2.8' into 'main' (#319)
- see https://github.com/aspnet/AspNetWebStack/releases/tag/v3.2.8 for prominent issues resolved as well as a more detailed list of changes Co-authored-by: Pranav Krishnamoorthy <[email protected]> Co-authored-by: Pranav K <[email protected]> Co-authored-by: dotnet-bot <[email protected]>
1 parent f7321b3 commit 646f452

17 files changed

+91
-38
lines changed

src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
namespace System.Net.Http.Formatting.Parsers
1111
{
1212
/// <summary>
13-
/// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header
14-
/// fields used in HTTP and MIME message entities.
13+
/// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header
14+
/// fields used in HTTP and MIME message entities.
1515
/// </summary>
1616
internal class InternetMessageFormatHeaderParser
1717
{
@@ -76,7 +76,7 @@ private enum HeaderFieldState
7676

7777
/// <summary>
7878
/// Parse a buffer of RFC 5322 style header fields and add them to the <see cref="HttpHeaders"/> collection.
79-
/// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be
79+
/// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be
8080
/// present in the buffer.
8181
/// </summary>
8282
/// <param name="buffer">Request buffer from where request is read</param>
@@ -283,7 +283,7 @@ private static ParserState ParseHeaderFields(
283283
}
284284

285285
/// <summary>
286-
/// Maintains information about the current header field being parsed.
286+
/// Maintains information about the current header field being parsed.
287287
/// </summary>
288288
private class CurrentHeaderFieldStore
289289
{
@@ -320,6 +320,10 @@ public void CopyTo(HttpHeaders headers, bool ignoreHeaderValidation)
320320
{
321321
var name = _name.ToString();
322322
var value = _value.ToString().Trim(CurrentHeaderFieldStore._linearWhiteSpace);
323+
if (string.Equals("expires", name, StringComparison.OrdinalIgnoreCase))
324+
{
325+
ignoreHeaderValidation = true;
326+
}
323327

324328
if (ignoreHeaderValidation)
325329
{

src/System.Net.Http.Formatting/HttpContentMessageExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private static async Task<HttpRequestMessage> ReadAsHttpRequestMessageAsyncCore(
223223

224224
HttpUnsortedRequest httpRequest = new HttpUnsortedRequest();
225225
HttpRequestHeaderParser parser = new HttpRequestHeaderParser(httpRequest,
226-
HttpRequestHeaderParser.DefaultMaxRequestLineSize, maxHeaderSize);
226+
Math.Max(HttpRequestHeaderParser.DefaultMaxRequestLineSize, maxHeaderSize), maxHeaderSize);
227227
ParserState parseStatus;
228228

229229
byte[] buffer = new byte[bufferSize];

src/System.Net.Http.Formatting/PushStreamContent.cs

+23-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace System.Net.Http
1414
{
1515
/// <summary>
1616
/// Provides an <see cref="HttpContent"/> implementation that exposes an output <see cref="Stream"/>
17-
/// which can be written to directly. The ability to push data to the output stream differs from the
17+
/// which can be written to directly. The ability to push data to the output stream differs from the
1818
/// <see cref="StreamContent"/> where data is pulled and not pushed.
1919
/// </summary>
2020
public class PushStreamContent : HttpContent
@@ -24,8 +24,8 @@ public class PushStreamContent : HttpContent
2424
/// <summary>
2525
/// Initializes a new instance of the <see cref="PushStreamContent"/> class. The
2626
/// <paramref name="onStreamAvailable"/> action is called when an output stream
27-
/// has become available allowing the action to write to it directly. When the
28-
/// stream is closed, it will signal to the content that is has completed and the
27+
/// has become available allowing the action to write to it directly. When the
28+
/// stream is closed, it will signal to the content that it has completed and the
2929
/// HTTP request or response will be completed.
3030
/// </summary>
3131
/// <param name="onStreamAvailable">The action to call when an output stream is available.</param>
@@ -35,10 +35,11 @@ public PushStreamContent(Action<Stream, HttpContent, TransportContext> onStreamA
3535
}
3636

3737
/// <summary>
38-
/// Initializes a new instance of the <see cref="PushStreamContent"/> class.
38+
/// Initializes a new instance of the <see cref="PushStreamContent"/> class.
3939
/// </summary>
40-
/// <param name="onStreamAvailable">The action to call when an output stream is available. The stream is automatically
41-
/// closed when the return task is completed.</param>
40+
/// <param name="onStreamAvailable">The action to call when an output stream is available. When the
41+
/// output stream is closed or disposed, it will signal to the content that it has completed and the
42+
/// HTTP request or response will be completed.</param>
4243
public PushStreamContent(Func<Stream, HttpContent, TransportContext, Task> onStreamAvailable)
4344
: this(onStreamAvailable, (MediaTypeHeaderValue)null)
4445
{
@@ -47,6 +48,8 @@ public PushStreamContent(Func<Stream, HttpContent, TransportContext, Task> onStr
4748
/// <summary>
4849
/// Initializes a new instance of the <see cref="PushStreamContent"/> class with the given media type.
4950
/// </summary>
51+
/// <param name="onStreamAvailable">The action to call when an output stream is available.</param>
52+
/// <param name="mediaType">The value of the Content-Type content header on an HTTP response.</param>
5053
public PushStreamContent(Action<Stream, HttpContent, TransportContext> onStreamAvailable, string mediaType)
5154
: this(Taskify(onStreamAvailable), new MediaTypeHeaderValue(mediaType))
5255
{
@@ -55,6 +58,10 @@ public PushStreamContent(Action<Stream, HttpContent, TransportContext> onStreamA
5558
/// <summary>
5659
/// Initializes a new instance of the <see cref="PushStreamContent"/> class with the given media type.
5760
/// </summary>
61+
/// <param name="onStreamAvailable">The action to call when an output stream is available. When the
62+
/// output stream is closed or disposed, it will signal to the content that it has completed and the
63+
/// HTTP request or response will be completed.</param>
64+
/// <param name="mediaType">The value of the Content-Type content header on an HTTP response.</param>
5865
public PushStreamContent(Func<Stream, HttpContent, TransportContext, Task> onStreamAvailable, string mediaType)
5966
: this(onStreamAvailable, new MediaTypeHeaderValue(mediaType))
6067
{
@@ -63,6 +70,8 @@ public PushStreamContent(Func<Stream, HttpContent, TransportContext, Task> onStr
6370
/// <summary>
6471
/// Initializes a new instance of the <see cref="PushStreamContent"/> class with the given <see cref="MediaTypeHeaderValue"/>.
6572
/// </summary>
73+
/// <param name="onStreamAvailable">The action to call when an output stream is available.</param>
74+
/// <param name="mediaType">The value of the Content-Type content header on an HTTP response.</param>
6675
public PushStreamContent(Action<Stream, HttpContent, TransportContext> onStreamAvailable, MediaTypeHeaderValue mediaType)
6776
: this(Taskify(onStreamAvailable), mediaType)
6877
{
@@ -71,6 +80,10 @@ public PushStreamContent(Action<Stream, HttpContent, TransportContext> onStreamA
7180
/// <summary>
7281
/// Initializes a new instance of the <see cref="PushStreamContent"/> class with the given <see cref="MediaTypeHeaderValue"/>.
7382
/// </summary>
83+
/// <param name="onStreamAvailable">The action to call when an output stream is available. When the
84+
/// output stream is closed or disposed, it will signal to the content that it has completed and the
85+
/// HTTP request or response will be completed.</param>
86+
/// <param name="mediaType">The value of the Content-Type content header on an HTTP response.</param>
7487
public PushStreamContent(Func<Stream, HttpContent, TransportContext, Task> onStreamAvailable, MediaTypeHeaderValue mediaType)
7588
{
7689
if (onStreamAvailable == null)
@@ -98,8 +111,8 @@ private static Func<Stream, HttpContent, TransportContext, Task> Taskify(
98111
}
99112

100113
/// <summary>
101-
/// When this method is called, it calls the action provided in the constructor with the output
102-
/// stream to write to. Once the action has completed its work it closes the stream which will
114+
/// When this method is called, it calls the action provided in the constructor with the output
115+
/// stream to write to. Once the action has completed its work it closes the stream which will
103116
/// close this content instance and complete the HTTP request or response.
104117
/// </summary>
105118
/// <param name="stream">The <see cref="Stream"/> to which to write.</param>
@@ -142,8 +155,8 @@ public CompleteTaskOnCloseStream(Stream innerStream, TaskCompletionSource<bool>
142155

143156
#if NETFX_CORE
144157
[SuppressMessage(
145-
"Microsoft.Usage",
146-
"CA2215:Dispose methods should call base class dispose",
158+
"Microsoft.Usage",
159+
"CA2215:Dispose methods should call base class dispose",
147160
Justification = "See comments, this is intentional.")]
148161
protected override void Dispose(bool disposing)
149162
{

src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private static async Task<HttpContent> CreateBufferedRequestContentAsync(IOwinRe
275275
}
276276
else
277277
{
278-
buffer = new MemoryStream(contentLength.Value);
278+
buffer = new MemoryStream(Math.Min(4 * 1024, contentLength.Value));
279279
}
280280

281281
cancellationToken.ThrowIfCancellationRequested();

src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<owners>Microsoft</owners>
99
<projectUrl>http://www.asp.net/web-api</projectUrl>
1010
<repository type="git" url="https://github.com/aspnet/AspNetWebStack"/>
11-
<requireLicenseAcceptance>true</requireLicenseAcceptance>
12-
<licenseUrl>http://www.microsoft.com/web/webpi/eula/mvc4extensions_prerelease_eula.htm</licenseUrl>
1311
<description>The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site. Visitors to your help page can use this content to learn how to call your web APIs. Everything generated by the help page is fully customizable using ASP.NET MVC and Razor. ASP.NET Web API Help Page is a great addition to any ASP.NET Web API project.</description>
1412
<summary>The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site.</summary>
1513
<dependencies>

src/WebApiHelpPage/WebApiHelpPage.nuspec

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<owners>Microsoft</owners>
99
<projectUrl>http://www.asp.net/web-api</projectUrl>
1010
<repository type="git" url="https://github.com/aspnet/AspNetWebStack"/>
11-
<requireLicenseAcceptance>true</requireLicenseAcceptance>
12-
<licenseUrl>http://www.microsoft.com/web/webpi/eula/mvc4extensions_prerelease_eula.htm</licenseUrl>
1311
<description>The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site. Visitors to your help page can use this content to learn how to call your web APIs. Everything generated by the help page is fully customizable using ASP.NET MVC and Razor. ASP.NET Web API Help Page is a great addition to any ASP.NET Web API project.</description>
1412
<summary>The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site.</summary>
1513
<dependencies>
@@ -22,7 +20,7 @@
2220
<frameworkAssembly assemblyName="System.ComponentModel.DataAnnotations" />
2321
</frameworkAssemblies>
2422
<language>en-US</language>
25-
<tags>Microsoft AspNet WebApi AspNetWebApi HelpPage</tags>
23+
<tags>Microsoft AspNet WebApi AspNetWebApi HelpPage</tags>
2624
</metadata>
2725
<files>
2826
<file src="Areas\HelpPage\App_Start\HelpPageConfig.cs.pp" target="content\Areas\HelpPage\App_Start\HelpPageConfig.cs.pp" />

test/Microsoft.TestCommon/PlatformInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private static Platform GetPlatform()
2626
{
2727
if (Type.GetType(_netCore20TypeName, throwOnError: false) != null)
2828
{
29-
// Treat .NET Core 2.0 as a .NET 4.5 superset though internal types are different.
29+
// Treat .NET Core 2.1 as a .NET 4.5 superset though internal types are different.
3030
return Platform.Net45;
3131
}
3232

test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
55
<RootNamespace>System.Net.Http</RootNamespace>
66
<AssemblyName>System.Net.Http.Formatting.NetStandard.Test</AssemblyName>
77
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>

test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ public static TheoryDataSet<string, string, bool> ReadAndWriteCorrectCharacterEn
302302
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true },
303303
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true },
304304
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false },
305-
#if !NETCOREAPP2_0 // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.0.
305+
#if !NETCOREAPP // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.1.
306306
{ "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false },
307307
#endif
308308
{ "This is a test æøå string written using iso-8859-1", "iso-8859-1", false },
309-
#if !NETCOREAPP2_0
309+
#if !NETCOREAPP
310310
{ "This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false },
311311
#endif
312312
};

test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull(
415415
Assert.Null(readObj);
416416
}
417417

418-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0 except at top level (using BsonMediaTypeformatter special case).
418+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1 except at top level (using BsonMediaTypeformatter special case).
419419
[Theory]
420420
[TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AsDictionary)]
421421
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull_Dictionary(Type variationType, object testData)

test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_KnownTypes(Ty
157157
}
158158
}
159159

160-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
160+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
161161
// Test alternate null value
162162
[Fact]
163163
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNull()

test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync(Type variatio
374374
}
375375
}
376376

377-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
377+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
378378
// Test alternate null value; always serialized as "null"
379379
[Theory]
380380
[TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AllSingleInstances)]

test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public Task DeserializingDeepArraysThrows()
258258
// low surrogate not preceded by high surrogate
259259
[InlineData("ABC \\udc00\\ud800 DEF", "ABC \ufffd\ufffd DEF")]
260260
// make sure unencoded invalid surrogate characters don't make it through
261-
#if NETCOREAPP2_0 // Json.NET uses its regular invalid Unicode character on .NET Core 2.0; '?' elsewhere.
261+
#if NETCOREAPP // Json.NET uses its regular invalid Unicode character on .NET Core 2.1; '?' elsewhere.
262262
[InlineData("\udc00\ud800\ud800", "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd")]
263263
#else
264264
[InlineData("\udc00\ud800\ud800", "??????")]

test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class XmlMediaTypeFormatterTests : MediaTypeFormatterTestBase<XmlMediaTyp
3636
Int32.MaxValue,
3737
Int64.MinValue,
3838
Int64.MaxValue,
39-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
39+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
4040
DBNull.Value,
4141
#endif
4242
});
@@ -484,7 +484,7 @@ public async Task ReadFromStream_AsyncRoundTripsWriteToStreamUsingDataContractSe
484484
}
485485
}
486486

487-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
487+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
488488
[Fact]
489489
public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsyncUsingDataContractSerializer_DBNull()
490490
{

test/System.Net.Http.Formatting.Test/HttpContentMessageExtensionsTests.cs

+37-3
Original file line numberDiff line numberDiff line change
@@ -482,16 +482,50 @@ public Task ReadAsHttpResponseMessageAsync_LargeHeaderSize()
482482
}
483483

484484
[Fact]
485-
public Task ReadAsHttpRequestMessageAsync_LargeHeaderSize()
485+
public async Task ReadAsHttpRequestMessageAsync_LargeHeaderSize()
486486
{
487+
string cookieValue = string.Format("{0}={1}", new String('a', 16 * 1024), new String('b', 16 * 1024));
487488
string[] request = new[] {
488489
@"GET / HTTP/1.1",
489490
@"Host: msdn.microsoft.com",
490-
String.Format("Cookie: {0}={1}", new String('a', 16 * 1024), new String('b', 16 * 1024))
491+
string.Format("Cookie: {0}", cookieValue),
492+
};
493+
494+
HttpContent content = CreateContent(true, request, "sample body");
495+
var httpRequestMessage = await content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, 64 * 1024, 64 * 1024);
496+
497+
Assert.Equal(HttpMethod.Get, httpRequestMessage.Method);
498+
Assert.Equal("/", httpRequestMessage.RequestUri.PathAndQuery);
499+
Assert.Equal("msdn.microsoft.com", httpRequestMessage.Headers.Host);
500+
IEnumerable<string> actualCookieValue;
501+
Assert.True(httpRequestMessage.Headers.TryGetValues("Cookie", out actualCookieValue));
502+
Assert.Equal(cookieValue, Assert.Single(actualCookieValue));
503+
}
504+
505+
[Fact]
506+
public async Task ReadAsHttpRequestMessageAsync_LargeHttpRequestLine()
507+
{
508+
string requestPath = string.Format("/myurl?{0}={1}", new string('a', 4 * 1024), new string('b', 4 * 1024));
509+
string cookieValue = string.Format("{0}={1}", new String('a', 4 * 1024), new String('b', 4 * 1024));
510+
string[] request = new[]
511+
{
512+
string.Format("GET {0} HTTP/1.1", requestPath),
513+
@"Host: msdn.microsoft.com",
514+
string.Format("Cookie: {0}", cookieValue),
491515
};
492516

493517
HttpContent content = CreateContent(true, request, "sample body");
494-
return content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, 64 * 1024, 64 * 1024);
518+
var httpRequestMessage = await content.ReadAsHttpRequestMessageAsync(
519+
Uri.UriSchemeHttp,
520+
bufferSize: 64 * 1024,
521+
maxHeaderSize: 64 * 1024);
522+
523+
Assert.Equal(HttpMethod.Get, httpRequestMessage.Method);
524+
Assert.Equal(requestPath, httpRequestMessage.RequestUri.PathAndQuery);
525+
Assert.Equal("msdn.microsoft.com", httpRequestMessage.Headers.Host);
526+
IEnumerable<string> actualCookieValue;
527+
Assert.True(httpRequestMessage.Headers.TryGetValues("Cookie", out actualCookieValue));
528+
Assert.Equal(cookieValue, Assert.Single(actualCookieValue));
495529
}
496530

497531
[Theory]

test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace System.Net.Http.Internal
1414
{
1515
public class HttpValueCollectionTest
1616
{
17-
#if !NETCOREAPP2_0 // Unused on .NET Core 2.0.
17+
#if !NETCOREAPP // Unused on .NET Core 2.1.
1818
private static readonly int _maxCollectionKeys = 1000;
1919
#endif
2020

@@ -148,7 +148,7 @@ public void Create_CreatesEmptyCollection()
148148
Assert.Empty(nvc);
149149
}
150150

151-
#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0.
151+
#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1.
152152
// This set of tests requires running on a separate appdomain so we don't
153153
// touch the static property MediaTypeFormatter.MaxHttpCollectionKeys.
154154
[Fact]

0 commit comments

Comments
 (0)