You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@@ -1,3 +1,7 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Microsoft.Design", "CA2237", Scope = "type", Target = "System.Net.FtpWebRequest")]
|
||||
|
||||
3
external/corefx/src/System.Net.Requests/src/MatchingRefApiCompatBaseline.txt
vendored
Normal file
3
external/corefx/src/System.Net.Requests/src/MatchingRefApiCompatBaseline.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Compat issues with assembly System.Net.Requests:
|
||||
MembersMustExist : Member 'System.Net.HttpWebRequest..ctor()' does not exist in the implementation but it does exist in the contract.
|
||||
Total Issues: 1
|
||||
@@ -6,6 +6,7 @@
|
||||
<RootNamespace>System.Net.Requests</RootNamespace>
|
||||
<AssemblyName>System.Net.Requests</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
|
||||
@@ -140,4 +141,4 @@
|
||||
<Reference Include="System.Threading.Thread" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -398,5 +398,8 @@ namespace System.Net
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static DateTime StringToDate(string s) =>
|
||||
HttpDateParse.ParseHttpDate(s, out DateTime dtOut) ? dtOut : throw new ProtocolViolationException(SR.net_baddate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1164,7 +1164,7 @@ namespace System.Net
|
||||
|
||||
if (_hostUri != null)
|
||||
{
|
||||
request.Headers.Host = _hostUri.Host;
|
||||
request.Headers.Host = Host;
|
||||
}
|
||||
|
||||
// Copy the HttpWebRequest request headers from the WebHeaderCollection into HttpRequestMessage.Headers and
|
||||
@@ -1451,7 +1451,7 @@ namespace System.Net
|
||||
{
|
||||
return DateTime.MinValue; // MinValue means header is not present
|
||||
}
|
||||
return StringToDate(headerValue);
|
||||
return HttpDateParse.StringToDate(headerValue);
|
||||
#if DEBUG
|
||||
}
|
||||
#endif
|
||||
@@ -1472,20 +1472,6 @@ namespace System.Net
|
||||
#endif
|
||||
}
|
||||
|
||||
// parse String to DateTime format.
|
||||
private static DateTime StringToDate(String S)
|
||||
{
|
||||
DateTime dtOut;
|
||||
if (HttpDateParse.ParseHttpDate(S, out dtOut))
|
||||
{
|
||||
return dtOut;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ProtocolViolationException(SR.net_baddate);
|
||||
}
|
||||
}
|
||||
|
||||
// convert Date to String using RFC 1123 pattern
|
||||
private static string DateToString(DateTime D)
|
||||
{
|
||||
|
||||
@@ -151,13 +151,11 @@ namespace System.Net
|
||||
{
|
||||
return DateTime.Now;
|
||||
}
|
||||
DateTime dtOut;
|
||||
HttpDateParse.ParseHttpDate(lastmodHeaderValue, out dtOut);
|
||||
return dtOut;
|
||||
|
||||
return HttpDateParse.StringToDate(lastmodHeaderValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>
|
||||
/// Gets the name of the server that sent the response.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -112,5 +113,28 @@ namespace System.Net
|
||||
|
||||
return exception;
|
||||
}
|
||||
|
||||
private static WebExceptionStatus GetStatusFromExceptionHelper(HttpRequestException ex)
|
||||
{
|
||||
SocketException socketEx = ex.InnerException as SocketException;
|
||||
|
||||
if (socketEx is null)
|
||||
{
|
||||
return WebExceptionStatus.UnknownError;
|
||||
}
|
||||
|
||||
WebExceptionStatus status;
|
||||
switch (socketEx.SocketErrorCode)
|
||||
{
|
||||
case SocketError.HostNotFound:
|
||||
status = WebExceptionStatus.NameResolutionFailure;
|
||||
break;
|
||||
default:
|
||||
status = WebExceptionStatus.UnknownError;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace System.Net
|
||||
status = WebExceptionStatus.NameResolutionFailure;
|
||||
break;
|
||||
default:
|
||||
status = WebExceptionStatus.UnknownError;
|
||||
status = GetStatusFromExceptionHelper(ex);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace System.Net
|
||||
status = WebExceptionStatus.NameResolutionFailure;
|
||||
break;
|
||||
default:
|
||||
status = WebExceptionStatus.UnknownError;
|
||||
status = GetStatusFromExceptionHelper(ex);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace System.Net.Tests
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(uri);
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server);
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync();
|
||||
using (WebResponse response = await getResponse)
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => request.AutomaticDecompression = DecompressionMethods.Deflate);
|
||||
@@ -188,6 +188,29 @@ namespace System.Net.Tests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HttpWebRequest_SetHostHeader_ContainsPortNumber()
|
||||
{
|
||||
await LoopbackServer.CreateServerAsync(async (server, uri) =>
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(uri);
|
||||
string host = uri.Host + ":" + uri.Port;
|
||||
request.Host = host;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
|
||||
await server.AcceptConnectionAsync(async connection =>
|
||||
{
|
||||
List<string> headers = await connection.ReadRequestHeaderAndSendResponseAsync();
|
||||
Assert.Contains($"Host: {host}", headers);
|
||||
});
|
||||
|
||||
using (var response = (HttpWebResponse) await getResponse)
|
||||
{
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Theory, MemberData(nameof(EchoServers))]
|
||||
public void MaximumResponseHeadersLength_SetNegativeTwo_ThrowsArgumentOutOfRangeException(Uri remoteServer)
|
||||
{
|
||||
@@ -682,14 +705,7 @@ namespace System.Net.Tests
|
||||
public void ServicePoint_GetValue_ExpectedResult(Uri remoteServer)
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(remoteServer);
|
||||
if (PlatformDetection.IsFullFramework)
|
||||
{
|
||||
Assert.NotNull(request.ServicePoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Throws<PlatformNotSupportedException>(() => request.ServicePoint);
|
||||
}
|
||||
Assert.NotNull(request.ServicePoint);
|
||||
}
|
||||
|
||||
[Theory, MemberData(nameof(EchoServers))]
|
||||
@@ -752,7 +768,7 @@ namespace System.Net.Tests
|
||||
request.ProtocolVersion = requestVersion;
|
||||
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
Task<List<string>> serverTask = LoopbackServer.ReadRequestAndSendResponseAsync(server);
|
||||
Task<List<string>> serverTask = server.AcceptConnectionSendResponseAndCloseAsync();
|
||||
|
||||
using (HttpWebResponse response = (HttpWebResponse) await getResponse)
|
||||
{
|
||||
|
||||
@@ -31,13 +31,7 @@ namespace System.Net.Tests
|
||||
request.ContinueDelegate = continueDelegate;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {utcNow:R}\r\n" +
|
||||
"Content-Type: application/json;charset=UTF-8\r\n" +
|
||||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"12345");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, "Content-Type: application/json;charset=UTF-8\r\n", "12345");
|
||||
Assert.Equal(continueDelegate, request.ContinueDelegate);
|
||||
});
|
||||
}
|
||||
@@ -52,13 +46,7 @@ namespace System.Net.Tests
|
||||
request.Method = HttpMethod.Get.Method;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {utcNow:R}\r\n" +
|
||||
"Content-Type: application/json;charset=UTF-8\r\n" +
|
||||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"12345");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, "Content-Type: application/json;charset=UTF-8\r\n", "12345");
|
||||
|
||||
using (WebResponse response = await getResponse)
|
||||
{
|
||||
@@ -85,13 +73,7 @@ namespace System.Net.Tests
|
||||
request.Method = HttpMethod.Get.Method;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {utcNow:R}\r\n" +
|
||||
"Content-Type: application/json;charset=UTF-8\r\n" +
|
||||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"12345");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, "Content-Type: application/json;charset=UTF-8\r\n", "12345");
|
||||
WebResponse response = await getResponse;
|
||||
HttpWebResponse httpResponse = (HttpWebResponse)response;
|
||||
httpResponse.Close();
|
||||
@@ -111,6 +93,40 @@ namespace System.Net.Tests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LastModified_ValidDate_Success()
|
||||
{
|
||||
DateTime expected = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2018, 4, 10, 3, 4, 5, DateTimeKind.Utc), TimeZoneInfo.Local);
|
||||
await LoopbackServer.CreateServerAsync(async (server, url) =>
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(url);
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, "Last-Modified: Tue, 10 Apr 2018 03:04:05 GMT\r\n", "12345");
|
||||
|
||||
using (HttpWebResponse response = (HttpWebResponse)(await getResponse))
|
||||
{
|
||||
Assert.Equal(expected, response.LastModified);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LastModified_InvalidDate_Throws()
|
||||
{
|
||||
DateTime expected = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2018, 4, 10, 3, 4, 5, DateTimeKind.Utc), TimeZoneInfo.Local);
|
||||
await LoopbackServer.CreateServerAsync(async (server, url) =>
|
||||
{
|
||||
HttpWebRequest request = WebRequest.CreateHttp(url);
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, "Last-Modified: invalid date\r\n", "12345");
|
||||
|
||||
using (HttpWebResponse response = (HttpWebResponse)(await getResponse))
|
||||
{
|
||||
Assert.Throws<ProtocolViolationException>(() => response.LastModified);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HttpWebResponse_Serialize_ExpectedResult()
|
||||
{
|
||||
@@ -120,11 +136,7 @@ namespace System.Net.Tests
|
||||
request.Method = HttpMethod.Get.Method;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
DateTimeOffset utcNow = DateTimeOffset.UtcNow;
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {utcNow:R}\r\n" +
|
||||
"Content-Length: 0\r\n" +
|
||||
"\r\n");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync();
|
||||
|
||||
using (WebResponse response = await getResponse)
|
||||
{
|
||||
@@ -146,6 +158,6 @@ namespace System.Net.Tests
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,7 @@ namespace System.Net.Tests
|
||||
HttpWebRequest request = WebRequest.CreateHttp(url);
|
||||
request.Method = HttpMethod.Get.Method;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {DateTimeOffset.UtcNow:R}\r\n" +
|
||||
$"Content-Type: {expectedContentType}\r\n" +
|
||||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"12345");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.OK, $"Content-Type: {expectedContentType}\r\n", "12345");
|
||||
|
||||
using (WebResponse response = await getResponse)
|
||||
{
|
||||
@@ -46,12 +40,7 @@ namespace System.Net.Tests
|
||||
HttpWebRequest request = WebRequest.CreateHttp(url);
|
||||
request.Method = HttpMethod.Get.Method;
|
||||
Task<WebResponse> getResponse = request.GetResponseAsync();
|
||||
await LoopbackServer.ReadRequestAndSendResponseAsync(server,
|
||||
$"HTTP/1.1 200 OK\r\n" +
|
||||
$"Date: {DateTimeOffset.UtcNow:R}\r\n" +
|
||||
"Content-Length: 5\r\n" +
|
||||
"\r\n" +
|
||||
"12345");
|
||||
await server.AcceptConnectionSendResponseAndCloseAsync(content: "12345");
|
||||
|
||||
using (WebResponse response = await getResponse)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<Compile Include="$(CommonTestPath)\System\Net\Http\LoopbackServer.cs">
|
||||
<Link>Common\System\Net\Http\LoopbackServer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
|
||||
<Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
|
||||
</Compile>
|
||||
<ProjectReference Include="$(CommonTestPath)\System\Diagnostics\RemoteExecutorConsoleApp\RemoteExecutorConsoleApp.csproj">
|
||||
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
|
||||
<Name>RemoteExecutorConsoleApp</Name>
|
||||
|
||||
Reference in New Issue
Block a user