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/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/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) { 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(); 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/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 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 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] diff --git a/test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs b/test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs index 8e06557b4..626c655aa 100644 --- a/test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs +++ b/test/System.Net.Http.Formatting.Test/Internal/HttpValueCollectionTest.cs @@ -14,7 +14,7 @@ namespace System.Net.Http.Internal { public class HttpValueCollectionTest { -#if !NETCOREAPP2_0 // Unused on .NET Core 2.0. +#if !NETCOREAPP // Unused on .NET Core 2.1. private static readonly int _maxCollectionKeys = 1000; #endif @@ -148,7 +148,7 @@ public void Create_CreatesEmptyCollection() Assert.Empty(nvc); } -#if !NETCOREAPP2_0 // DBNull not serializable on .NET Core 2.0. +#if !NETCOREAPP // DBNull not serializable on .NET Core 2.1. // This set of tests requires running on a separate appdomain so we don't // touch the static property MediaTypeFormatter.MaxHttpCollectionKeys. [Fact] diff --git a/test/System.Net.Http.Formatting.Test/MultipartFileStreamProviderTests.cs b/test/System.Net.Http.Formatting.Test/MultipartFileStreamProviderTests.cs index 6e62bef0e..0cc9c5b7a 100644 --- a/test/System.Net.Http.Formatting.Test/MultipartFileStreamProviderTests.cs +++ b/test/System.Net.Http.Formatting.Test/MultipartFileStreamProviderTests.cs @@ -32,6 +32,7 @@ public class MultipartFileStreamProviderTests : MultipartStreamProviderTestBase< private const int ValidBufferSize = 0x111; private const string ValidPath = @"c:\some\path"; +#if !NETCOREAPP // .NET Core does not enforce path validity in many APIs. public static TheoryDataSet 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")]