From ffbf707ddd657e93975131f462c8e4653836ba18 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Tue, 27 Apr 2021 22:37:54 -0700 Subject: [PATCH 1/7] Move to a current .NET SDK --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index ea2669b29..3e8915949 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.403" + "version": "2.1.523" } -} \ No newline at end of file +} From bc83a3a7ec8354c0a5fa919a5317219f21e905a0 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Sun, 2 May 2021 11:00:40 -0700 Subject: [PATCH 2/7] Rebrand to v3.2.8 / v5.2.8 (#298) - reformat README.md - merge 'Git tag' and 'Git branch' columns - remove old v3.2.4 / v5.2.4 information - add v3.2.7 / v5.2.7 information --- README.md | 19 ++++++++++--------- src/CommonAssemblyInfo.cs | 4 ++-- src/CommonAssemblyInfo.vb | 4 ++-- .../Areas/HelpPage/Views/Web.config | 2 +- .../VB/Areas/HelpPage/Views/Web.config | 2 +- .../Test/VersionTest.cs | 2 +- test/System.Web.WebPages.Test/App.config | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 380713f64..f53c1b73f 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ Check out the [contributing](CONTRIBUTING.md) page to see the best places to log ### Tags and releases -Git tag|Git branch|Other products|MVC package versions|Web API package (product) versions|Web Pages package versions ---------|--------------|------------|------------|------------|------------ -[v2.0.4](https://github.com/aspnet/AspNetWebStack/tree/v2.0.4)|[v2.0-rtm](https://github.com/aspnet/AspNetWebStack/tree/v2.0-rtm)||4.0.40804|4.0.30506|2.0.30506 -[v2.1](https://github.com/aspnet/AspNetWebStack/tree/v2.1)||ASP.NET and Web Tools 2012.2, VS 2012 Update 2 (not on http://nuget.org)|v4 2012.2 Update RTM|v1 2012.2 Update RTM|v2 2012.2 Update RTM -[v3.0.2](https://github.com/aspnet/AspNetWebStack/tree/v3.0.2)|[v3-rtm](https://github.com/aspnet/AspNetWebStack/tree/v3-rtm)||5.0.2|5.0.1 (2.0.1)|3.0.1 -[v3.1.3](https://github.com/aspnet/AspNetWebStack/tree/v3.1.3)|[v3.1-rtm](https://github.com/aspnet/AspNetWebStack/tree/v3.1-rtm)||5.1.3|5.1.2 (2.1.2)|3.1.2 -[v3.2.4](https://github.com/aspnet/AspNetWebStack/tree/v3.2.4)|||5.2.4|5.2.4 (2.2.4)|3.2.4 -[v3.2.6](https://github.com/aspnet/AspNetWebStack/tree/v3.2.6)|||5.2.6|5.2.6|3.2.6 -||[master](https://github.com/aspnet/AspNetWebStack/tree/master)|New work e.g. MVC 5.2.7-preview1||| +Git tag or branch|Other products|MVC package versions|Web API package (product) versions|Web Pages package versions +--------|--------------|------------|------------|------------ +[v2.0.4](https://github.com/aspnet/AspNetWebStack/tree/v2.0.4)||4.0.40804|4.0.30506|2.0.30506 +[v2.1](https://github.com/aspnet/AspNetWebStack/tree/v2.1)|ASP.NET and Web Tools 2012.2, VS 2012 Update 2 (not on http://nuget.org)|v4 2012.2 Update RTM|v1 2012.2 Update RTM|v2 2012.2 Update RTM +[v3.0.2](https://github.com/aspnet/AspNetWebStack/tree/v3.0.2)||5.0.2|5.0.1 (2.0.1)|3.0.1 +[v3.1.3](https://github.com/aspnet/AspNetWebStack/tree/v3.1.3)||5.1.3|5.1.2 (2.1.2)|3.1.2 +[v3.2.6](https://github.com/aspnet/AspNetWebStack/tree/v3.2.6)||5.2.6|5.2.6|3.2.6 +[v3.2.7](https://github.com/aspnet/AspNetWebStack/tree/v3.2.7)||5.2.7|5.2.7|3.2.7 +[release/3.2.8](https://github.com/aspnet/AspNetWebStack/tree/release/3.2.8)|Work in progress on 5.2.8/3.2.8|||| +[main](https://github.com/aspnet/AspNetWebStack/tree/main)|New work e.g. MVC 5.2.9-preview1|||| diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index aa130a34b..ee493811f 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -28,8 +28,8 @@ #error Runtime projects cannot define more than one of ASPNETMVC, ASPNETWEBPAGES or ASPNETFACEBOOK #elif ASPNETMVC #if !BUILD_GENERATED_VERSION -[assembly: AssemblyVersion("5.2.7.0")] // ASPNETMVC -[assembly: AssemblyFileVersion("5.2.7.0")] // ASPNETMVC +[assembly: AssemblyVersion("5.2.8.0")] // ASPNETMVC +[assembly: AssemblyFileVersion("5.2.8.0")] // ASPNETMVC #endif [assembly: AssemblyProduct("Microsoft ASP.NET MVC")] #elif ASPNETWEBPAGES diff --git a/src/CommonAssemblyInfo.vb b/src/CommonAssemblyInfo.vb index 8310810f3..6d108b5ff 100644 --- a/src/CommonAssemblyInfo.vb +++ b/src/CommonAssemblyInfo.vb @@ -20,6 +20,6 @@ Imports System.Runtime.InteropServices ' Version numbers are automatically generated based on regular expressions. ' =========================================================================== - 'ASPNETMVC - 'ASPNETMVC + 'ASPNETMVC + 'ASPNETMVC \ No newline at end of file diff --git a/src/WebApiHelpPage/Areas/HelpPage/Views/Web.config b/src/WebApiHelpPage/Areas/HelpPage/Views/Web.config index 820e75486..6d4ddaf10 100644 --- a/src/WebApiHelpPage/Areas/HelpPage/Views/Web.config +++ b/src/WebApiHelpPage/Areas/HelpPage/Views/Web.config @@ -9,7 +9,7 @@ - + diff --git a/src/WebApiHelpPage/VB/Areas/HelpPage/Views/Web.config b/src/WebApiHelpPage/VB/Areas/HelpPage/Views/Web.config index 9a921ab54..6496e10d7 100644 --- a/src/WebApiHelpPage/VB/Areas/HelpPage/Views/Web.config +++ b/src/WebApiHelpPage/VB/Areas/HelpPage/Views/Web.config @@ -9,7 +9,7 @@ - + diff --git a/test/Microsoft.Web.Mvc.Test/Test/VersionTest.cs b/test/Microsoft.Web.Mvc.Test/Test/VersionTest.cs index 155f13f2f..8554639ae 100644 --- a/test/Microsoft.Web.Mvc.Test/Test/VersionTest.cs +++ b/test/Microsoft.Web.Mvc.Test/Test/VersionTest.cs @@ -13,7 +13,7 @@ public class VersionTest public void VerifyMVCVersionChangesAreIntentional() { Version mvcVersion = VersionTestHelper.GetVersionFromAssembly("System.Web.Mvc", typeof(Controller)); - Assert.Equal(new Version(5, 2, 7, 0), mvcVersion); + Assert.Equal(new Version(5, 2, 8, 0), mvcVersion); } } } diff --git a/test/System.Web.WebPages.Test/App.config b/test/System.Web.WebPages.Test/App.config index 0f0603365..61f560828 100644 --- a/test/System.Web.WebPages.Test/App.config +++ b/test/System.Web.WebPages.Test/App.config @@ -11,7 +11,7 @@ - + From c55dd95aebb2069c8c381535628e952baef35eab Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Thu, 29 Jul 2021 11:35:00 -0700 Subject: [PATCH 3/7] [releaes/3.2.8] Get builds working again (#302) - test using netcoreapp2.1 - react to .NET Core breaking change - see https://docs.microsoft.com/en-us/dotnet/core/compatibility/2.1#path-apis-dont-throw-an-exception-for-invalid-characters - suppress NU5125 warnings - break the build because warnings are treated as errors - do not validate Expires header values - #263 --- .../Parsers/InternetMessageFormatHeaderParser.cs | 12 ++++++++---- src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj | 2 ++ src/WebApiHelpPage/WebApiHelpPage.csproj | 2 ++ test/Microsoft.TestCommon/PlatformInfo.cs | 2 +- ...ystem.Net.Http.Formatting.NetStandard.Test.csproj | 2 +- .../DataSets/HttpTestData.cs | 4 ++-- .../Formatting/BsonMediaTypeFormatterTests.cs | 2 +- .../DataContractJsonMediaTypeFormatterTests.cs | 2 +- .../Formatting/JsonMediaTypeFormatterTests.cs | 2 +- .../Formatting/JsonNetSerializationTest.cs | 2 +- .../Formatting/XmlMediaTypeFormatterTests.cs | 4 ++-- .../Internal/HttpValueCollectionTest.cs | 4 ++-- .../MultipartFileStreamProviderTests.cs | 10 ++++++++-- 13 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs b/src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs index aebfa8c29..ebf22b9ba 100644 --- a/src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs +++ b/src/System.Net.Http.Formatting/Formatting/Parsers/InternetMessageFormatHeaderParser.cs @@ -10,8 +10,8 @@ namespace System.Net.Http.Formatting.Parsers { /// - /// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header - /// fields used in HTTP and MIME message entities. + /// Buffer-oriented RFC 5322 style Internet Message Format parser which can be used to pass header + /// fields used in HTTP and MIME message entities. /// internal class InternetMessageFormatHeaderParser { @@ -76,7 +76,7 @@ private enum HeaderFieldState /// /// Parse a buffer of RFC 5322 style header fields and add them to the collection. - /// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be + /// Bytes are parsed in a consuming manner from the beginning of the buffer meaning that the same bytes can not be /// present in the buffer. /// /// Request buffer from where request is read @@ -283,7 +283,7 @@ private static ParserState ParseHeaderFields( } /// - /// Maintains information about the current header field being parsed. + /// Maintains information about the current header field being parsed. /// private class CurrentHeaderFieldStore { @@ -320,6 +320,10 @@ public void CopyTo(HttpHeaders headers, bool ignoreHeaderValidation) { var name = _name.ToString(); var value = _value.ToString().Trim(CurrentHeaderFieldStore._linearWhiteSpace); + if (string.Equals("expires", name, StringComparison.OrdinalIgnoreCase)) + { + ignoreHeaderValidation = true; + } if (ignoreHeaderValidation) { diff --git a/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj b/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj index 5c1d45882..116d126b7 100644 --- a/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj +++ b/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj @@ -11,6 +11,8 @@ $(CodeAnalysis) ..\..\Strict.ruleset Windows + + $(NoWarn);NU5125 true diff --git a/src/WebApiHelpPage/WebApiHelpPage.csproj b/src/WebApiHelpPage/WebApiHelpPage.csproj index 15964d7c8..38c333f6b 100644 --- a/src/WebApiHelpPage/WebApiHelpPage.csproj +++ b/src/WebApiHelpPage/WebApiHelpPage.csproj @@ -13,6 +13,8 @@ ..\Strict.ruleset $(DefineConstants);ASPNETMVC 1591 + + $(NoWarn);NU5125 diff --git a/test/Microsoft.TestCommon/PlatformInfo.cs b/test/Microsoft.TestCommon/PlatformInfo.cs index 678ecff08..e3026e39e 100644 --- a/test/Microsoft.TestCommon/PlatformInfo.cs +++ b/test/Microsoft.TestCommon/PlatformInfo.cs @@ -26,7 +26,7 @@ private static Platform GetPlatform() { if (Type.GetType(_netCore20TypeName, throwOnError: false) != null) { - // Treat .NET Core 2.0 as a .NET 4.5 superset though internal types are different. + // Treat .NET Core 2.1 as a .NET 4.5 superset though internal types are different. return Platform.Net45; } diff --git a/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj b/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj index 31732bd10..6cfb16e25 100644 --- a/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj +++ b/test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0;net461 + netcoreapp2.1;net461 System.Net.Http System.Net.Http.Formatting.NetStandard.Test ..\..\bin\$(Configuration)\Test\ diff --git a/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs b/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs index fb482788b..84178a3a6 100644 --- a/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs +++ b/test/System.Net.Http.Formatting.Test/DataSets/HttpTestData.cs @@ -302,11 +302,11 @@ public static TheoryDataSet ReadAndWriteCorrectCharacterEn { "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true }, { "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true }, { "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false }, -#if !NETCOREAPP2_0 // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.0. +#if !NETCOREAPP // shift_jis and iso-2022-kr are not supported when running on .NET Core 2.1. { "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false }, #endif { "This is a test æøå string written using iso-8859-1", "iso-8859-1", false }, -#if !NETCOREAPP2_0 +#if !NETCOREAPP { "This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false }, #endif }; diff --git a/test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs index d849df473..caf93e059 100644 --- a/test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs +++ b/test/System.Net.Http.Formatting.Test/Formatting/BsonMediaTypeFormatterTests.cs @@ -415,7 +415,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull( Assert.Null(readObj); } -#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0 except at top level (using BsonMediaTypeformatter special case). +#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1 except at top level (using BsonMediaTypeformatter special case). [Theory] [TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AsDictionary)] public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNullAsNull_Dictionary(Type variationType, object testData) diff --git a/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs index ad3311326..e576a6924 100644 --- a/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs +++ b/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs @@ -157,7 +157,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_KnownTypes(Ty } } -#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0. +#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1. // Test alternate null value [Fact] public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync_DBNull() diff --git a/test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs index 34d17d884..3d7898ddb 100644 --- a/test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs +++ b/test/System.Net.Http.Formatting.Test/Formatting/JsonMediaTypeFormatterTests.cs @@ -374,7 +374,7 @@ public async Task ReadFromStreamAsync_RoundTripsWriteToStreamAsync(Type variatio } } -#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0. +#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1. // Test alternate null value; always serialized as "null" [Theory] [TestDataSet(typeof(JsonMediaTypeFormatterTests), "DBNullAsObjectTestDataCollection", TestDataVariations.AllSingleInstances)] diff --git a/test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs b/test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs index b544752f0..bd0edfd20 100644 --- a/test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs +++ b/test/System.Net.Http.Formatting.Test/Formatting/JsonNetSerializationTest.cs @@ -258,7 +258,7 @@ public Task DeserializingDeepArraysThrows() // low surrogate not preceded by high surrogate [InlineData("ABC \\udc00\\ud800 DEF", "ABC \ufffd\ufffd DEF")] // make sure unencoded invalid surrogate characters don't make it through -#if NETCOREAPP2_0 // Json.NET uses its regular invalid Unicode character on .NET Core 2.0; '?' elsewhere. +#if NETCOREAPP // Json.NET uses its regular invalid Unicode character on .NET Core 2.1; '?' elsewhere. [InlineData("\udc00\ud800\ud800", "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd")] #else [InlineData("\udc00\ud800\ud800", "??????")] diff --git a/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs index b1865376b..3d7fd1557 100644 --- a/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs +++ b/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs @@ -36,7 +36,7 @@ public class XmlMediaTypeFormatterTests : MediaTypeFormatterTestBase NotSupportedFilePaths { get @@ -44,6 +45,7 @@ public static TheoryDataSet NotSupportedFilePaths }; } } +#endif public static TheoryDataSet InvalidFilePaths { @@ -52,15 +54,17 @@ public static TheoryDataSet InvalidFilePaths return new TheoryDataSet { "", - " ", + " ", " ", - "\t\t \n ", +#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs. + "\t\t \n ", "c:\\ab", "c:\\a\"b", "c:\\a\tb", "c:\\a|b", "c:\\a\bb", +#endif "c:\\a\0b", "c :\\a\0b", }; @@ -73,12 +77,14 @@ public void Constructor_ThrowsOnNullRootPath() Assert.ThrowsArgumentNull(() => { new MultipartFileStreamProvider(null); }, "rootPath"); } +#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs. [Theory] [PropertyData("NotSupportedFilePaths")] public void Constructor_ThrowsOnNotSupportedRootPath(string notSupportedPath) { Assert.Throws(() => new MultipartFileStreamProvider(notSupportedPath, ValidBufferSize)); } +#endif [Theory] [PropertyData("InvalidFilePaths")] From 8c4e5b5da1f7f0c348978c99f9a477f7928f7258 Mon Sep 17 00:00:00 2001 From: Pranav Krishnamoorthy Date: Wed, 6 Oct 2021 23:37:15 +0000 Subject: [PATCH 4/7] Merged PR 18778: Constrain the MemoryStream size Constrain the MemoryStream size --- src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs b/src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs index b8c6fc648..ac118a754 100644 --- a/src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs +++ b/src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs @@ -275,7 +275,7 @@ private static async Task CreateBufferedRequestContentAsync(IOwinRe } else { - buffer = new MemoryStream(contentLength.Value); + buffer = new MemoryStream(Math.Min(4 * 1024, contentLength.Value)); } cancellationToken.ThrowIfCancellationRequested(); From d1df0c8297eda63b3b3a9c6b0892f9e6ace49d9e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Jan 2022 15:49:37 -0800 Subject: [PATCH 5/7] Clean up doc comments for PushStreamContent (#311) Fixes https://github.com/aspnet/AspNetWebStack/issues/310 --- .../PushStreamContent.cs | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/System.Net.Http.Formatting/PushStreamContent.cs b/src/System.Net.Http.Formatting/PushStreamContent.cs index a8df4f262..6896e6c39 100644 --- a/src/System.Net.Http.Formatting/PushStreamContent.cs +++ b/src/System.Net.Http.Formatting/PushStreamContent.cs @@ -14,7 +14,7 @@ namespace System.Net.Http { /// /// Provides an implementation that exposes an output - /// which can be written to directly. The ability to push data to the output stream differs from the + /// which can be written to directly. The ability to push data to the output stream differs from the /// where data is pulled and not pushed. /// public class PushStreamContent : HttpContent @@ -24,8 +24,8 @@ public class PushStreamContent : HttpContent /// /// Initializes a new instance of the class. The /// action is called when an output stream - /// has become available allowing the action to write to it directly. When the - /// stream is closed, it will signal to the content that is has completed and the + /// has become available allowing the action to write to it directly. When the + /// stream is closed, it will signal to the content that it has completed and the /// HTTP request or response will be completed. /// /// The action to call when an output stream is available. @@ -35,10 +35,11 @@ public PushStreamContent(Action onStreamA } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The action to call when an output stream is available. The stream is automatically - /// closed when the return task is completed. + /// The action to call when an output stream is available. When the + /// output stream is closed or disposed, it will signal to the content that it has completed and the + /// HTTP request or response will be completed. public PushStreamContent(Func onStreamAvailable) : this(onStreamAvailable, (MediaTypeHeaderValue)null) { @@ -47,6 +48,8 @@ public PushStreamContent(Func onStr /// /// Initializes a new instance of the class with the given media type. /// + /// The action to call when an output stream is available. + /// The value of the Content-Type content header on an HTTP response. public PushStreamContent(Action onStreamAvailable, string mediaType) : this(Taskify(onStreamAvailable), new MediaTypeHeaderValue(mediaType)) { @@ -55,6 +58,10 @@ public PushStreamContent(Action onStreamA /// /// Initializes a new instance of the class with the given media type. /// + /// The action to call when an output stream is available. When the + /// output stream is closed or disposed, it will signal to the content that it has completed and the + /// HTTP request or response will be completed. + /// The value of the Content-Type content header on an HTTP response. public PushStreamContent(Func onStreamAvailable, string mediaType) : this(onStreamAvailable, new MediaTypeHeaderValue(mediaType)) { @@ -63,6 +70,8 @@ public PushStreamContent(Func onStr /// /// Initializes a new instance of the class with the given . /// + /// The action to call when an output stream is available. + /// The value of the Content-Type content header on an HTTP response. public PushStreamContent(Action onStreamAvailable, MediaTypeHeaderValue mediaType) : this(Taskify(onStreamAvailable), mediaType) { @@ -71,6 +80,10 @@ public PushStreamContent(Action onStreamA /// /// Initializes a new instance of the class with the given . /// + /// The action to call when an output stream is available. When the + /// output stream is closed or disposed, it will signal to the content that it has completed and the + /// HTTP request or response will be completed. + /// The value of the Content-Type content header on an HTTP response. public PushStreamContent(Func onStreamAvailable, MediaTypeHeaderValue mediaType) { if (onStreamAvailable == null) @@ -98,8 +111,8 @@ private static Func Taskify( } /// - /// When this method is called, it calls the action provided in the constructor with the output - /// stream to write to. Once the action has completed its work it closes the stream which will + /// When this method is called, it calls the action provided in the constructor with the output + /// stream to write to. Once the action has completed its work it closes the stream which will /// close this content instance and complete the HTTP request or response. /// /// The to which to write. @@ -142,8 +155,8 @@ public CompleteTaskOnCloseStream(Stream innerStream, TaskCompletionSource #if NETFX_CORE [SuppressMessage( - "Microsoft.Usage", - "CA2215:Dispose methods should call base class dispose", + "Microsoft.Usage", + "CA2215:Dispose methods should call base class dispose", Justification = "See comments, this is intentional.")] protected override void Dispose(bool disposing) { From ef4296eff8dac087d2b49e6a4af7eb6715f30dfc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 14 Jan 2022 13:47:15 -0800 Subject: [PATCH 6/7] Configure max request line size limits to be the same as maxHeaderSize (#312) * Configure max request line size limits to be the same as maxHeaderSize As part of ReadAsHttpRequestMessageAsync, the parsing of the HTTP request line is limited by a non-configurable 2k limit. The size does not affect buffer sizes, only the maximum allowed length. This PR updates the ReadAsHttpRequestMessageAsync API to use the same limits for HTTP request line as the HTTP header line, the latter which is configurable by user code. In the default case, this means the HTTP request line size now supports a 16k limit before it throws. Fixes https://github.com/aspnet/AspNetWebStack/issues/307 --- .../HttpContentMessageExtensions.cs | 2 +- .../HttpContentMessageExtensionsTests.cs | 40 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/System.Net.Http.Formatting/HttpContentMessageExtensions.cs b/src/System.Net.Http.Formatting/HttpContentMessageExtensions.cs index dd801b604..a7dcb869d 100644 --- a/src/System.Net.Http.Formatting/HttpContentMessageExtensions.cs +++ b/src/System.Net.Http.Formatting/HttpContentMessageExtensions.cs @@ -223,7 +223,7 @@ private static async Task ReadAsHttpRequestMessageAsyncCore( HttpUnsortedRequest httpRequest = new HttpUnsortedRequest(); HttpRequestHeaderParser parser = new HttpRequestHeaderParser(httpRequest, - HttpRequestHeaderParser.DefaultMaxRequestLineSize, maxHeaderSize); + Math.Max(HttpRequestHeaderParser.DefaultMaxRequestLineSize, maxHeaderSize), maxHeaderSize); ParserState parseStatus; byte[] buffer = new byte[bufferSize]; diff --git a/test/System.Net.Http.Formatting.Test/HttpContentMessageExtensionsTests.cs b/test/System.Net.Http.Formatting.Test/HttpContentMessageExtensionsTests.cs index 27273e4f2..7003cdbd5 100644 --- a/test/System.Net.Http.Formatting.Test/HttpContentMessageExtensionsTests.cs +++ b/test/System.Net.Http.Formatting.Test/HttpContentMessageExtensionsTests.cs @@ -482,16 +482,50 @@ public Task ReadAsHttpResponseMessageAsync_LargeHeaderSize() } [Fact] - public Task ReadAsHttpRequestMessageAsync_LargeHeaderSize() + public async Task ReadAsHttpRequestMessageAsync_LargeHeaderSize() { + string cookieValue = string.Format("{0}={1}", new String('a', 16 * 1024), new String('b', 16 * 1024)); string[] request = new[] { @"GET / HTTP/1.1", @"Host: msdn.microsoft.com", - String.Format("Cookie: {0}={1}", new String('a', 16 * 1024), new String('b', 16 * 1024)) + string.Format("Cookie: {0}", cookieValue), + }; + + HttpContent content = CreateContent(true, request, "sample body"); + var httpRequestMessage = await content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, 64 * 1024, 64 * 1024); + + Assert.Equal(HttpMethod.Get, httpRequestMessage.Method); + Assert.Equal("/", httpRequestMessage.RequestUri.PathAndQuery); + Assert.Equal("msdn.microsoft.com", httpRequestMessage.Headers.Host); + IEnumerable actualCookieValue; + Assert.True(httpRequestMessage.Headers.TryGetValues("Cookie", out actualCookieValue)); + Assert.Equal(cookieValue, Assert.Single(actualCookieValue)); + } + + [Fact] + public async Task ReadAsHttpRequestMessageAsync_LargeHttpRequestLine() + { + string requestPath = string.Format("/myurl?{0}={1}", new string('a', 4 * 1024), new string('b', 4 * 1024)); + string cookieValue = string.Format("{0}={1}", new String('a', 4 * 1024), new String('b', 4 * 1024)); + string[] request = new[] + { + string.Format("GET {0} HTTP/1.1", requestPath), + @"Host: msdn.microsoft.com", + string.Format("Cookie: {0}", cookieValue), }; HttpContent content = CreateContent(true, request, "sample body"); - return content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, 64 * 1024, 64 * 1024); + var httpRequestMessage = await content.ReadAsHttpRequestMessageAsync( + Uri.UriSchemeHttp, + bufferSize: 64 * 1024, + maxHeaderSize: 64 * 1024); + + Assert.Equal(HttpMethod.Get, httpRequestMessage.Method); + Assert.Equal(requestPath, httpRequestMessage.RequestUri.PathAndQuery); + Assert.Equal("msdn.microsoft.com", httpRequestMessage.Headers.Host); + IEnumerable actualCookieValue; + Assert.True(httpRequestMessage.Headers.TryGetValues("Cookie", out actualCookieValue)); + Assert.Equal(cookieValue, Assert.Single(actualCookieValue)); } [Theory] From 362b7be1e6df2cca6ff307f8fc303e6490dacc52 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Wed, 30 Mar 2022 14:02:44 -0700 Subject: [PATCH 7/7] Remove deprecated `` element (#315) - remove `` as well - can't require a license w/o `` or `` - also, don't need to ignore NU5125 anymore --- src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec | 2 -- src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj | 2 -- src/WebApiHelpPage/WebApiHelpPage.csproj | 2 -- src/WebApiHelpPage/WebApiHelpPage.nuspec | 4 +--- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec b/src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec index 6715ceca9..3e826d647 100644 --- a/src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec +++ b/src/WebApiHelpPage/VB/WebApiHelpPage.VB.nuspec @@ -8,8 +8,6 @@ Microsoft http://www.asp.net/web-api - true - http://www.microsoft.com/web/webpi/eula/mvc4extensions_prerelease_eula.htm 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. The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site. diff --git a/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj b/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj index 116d126b7..5c1d45882 100644 --- a/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj +++ b/src/WebApiHelpPage/VB/WebApiHelpPageVB.vbproj @@ -11,8 +11,6 @@ $(CodeAnalysis) ..\..\Strict.ruleset Windows - - $(NoWarn);NU5125 true diff --git a/src/WebApiHelpPage/WebApiHelpPage.csproj b/src/WebApiHelpPage/WebApiHelpPage.csproj index 38c333f6b..15964d7c8 100644 --- a/src/WebApiHelpPage/WebApiHelpPage.csproj +++ b/src/WebApiHelpPage/WebApiHelpPage.csproj @@ -13,8 +13,6 @@ ..\Strict.ruleset $(DefineConstants);ASPNETMVC 1591 - - $(NoWarn);NU5125 diff --git a/src/WebApiHelpPage/WebApiHelpPage.nuspec b/src/WebApiHelpPage/WebApiHelpPage.nuspec index aa69da71f..8c69a51b1 100644 --- a/src/WebApiHelpPage/WebApiHelpPage.nuspec +++ b/src/WebApiHelpPage/WebApiHelpPage.nuspec @@ -8,8 +8,6 @@ Microsoft http://www.asp.net/web-api - true - http://www.microsoft.com/web/webpi/eula/mvc4extensions_prerelease_eula.htm 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. The ASP.NET Web API Help Page automatically generates help page content for the web APIs on your site. @@ -22,7 +20,7 @@ en-US - Microsoft AspNet WebApi AspNetWebApi HelpPage + Microsoft AspNet WebApi AspNetWebApi HelpPage