Skip to content

Commit c63fbb7

Browse files
authoredNov 9, 2019
Clean up after CurlHandler removal (dotnet#42506)
Also fix some stragglers from the netfx and uap handler removals.
1 parent f546aa9 commit c63fbb7

29 files changed

+101
-536
lines changed
 

‎Documentation/building/unix-instructions.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ components
3737
* libc6-dev
3838
* libssl-dev
3939
* libkrb5-dev
40-
* libcurl4-openssl-dev
4140
* zlib1g-dev
4241

4342
`sudo apt-get install git clang-9 cmake make libc6-dev libssl-dev libkrb5-dev
44-
libcurl4-openssl-dev zlib1g-dev`
43+
zlib1g-dev`
4544

4645
#### Managed build
4746

‎Documentation/project-docs/developer-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ build /p:BuildNative=false
7575
build -clean
7676
```
7777
### Build Native
78-
The native build produces shims over libc, openssl, gssapi, libcurl and libz.
78+
The native build produces shims over libc, openssl, gssapi, and libz.
7979
The build system uses CMake to generate Makefiles using clang.
8080
The build also uses git for generating some version information.
8181

‎src/System.Net.Http/src/Resources/Strings.resx

+1-22
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@
276276
<data name="net_cookie_attribute" xml:space="preserve">
277277
<value>The '{0}'='{1}' part of the cookie is invalid.</value>
278278
</data>
279-
<data name="net_http_unix_invalid_credential" xml:space="preserve">
280-
<value>The libcurl library in use ({0}) does not support different credentials for different authentication schemes.</value>
281-
</data>
282-
<data name="net_http_unix_https_support_unavailable_libcurl" xml:space="preserve">
283-
<value>The libcurl library in use ({0}) does not support HTTPS.</value>
284-
</data>
285279
<data name="ArgumentOutOfRange_FileLengthTooBig" xml:space="preserve">
286280
<value>Specified file length was too large for the file system.</value>
287281
</data>
@@ -390,21 +384,6 @@
390384
<data name="ObjectDisposed_StreamClosed" xml:space="preserve">
391385
<value>Cannot access a closed stream.</value>
392386
</data>
393-
<data name="net_http_libcurl_callback_notsupported_sslbackend" xml:space="preserve">
394-
<value>The handler does not support custom handling of certificates with this combination of libcurl ({0}) and its SSL backend ("{1}"). An SSL backend based on "{2}" is required. Consider using System.Net.Http.SocketsHttpHandler.</value>
395-
</data>
396-
<data name="net_http_libcurl_callback_notsupported_os" xml:space="preserve">
397-
<value>The handler does not support custom handling of certificates on this operating system. Consider using System.Net.Http.SocketsHttpHandler.</value>
398-
</data>
399-
<data name="net_http_libcurl_clientcerts_notsupported_sslbackend" xml:space="preserve">
400-
<value>The handler does not support client authentication certificates with this combination of libcurl ({0}) and its SSL backend ("{1}"). An SSL backend based on "{2}" is required. Consider using System.Net.Http.SocketsHttpHandler.</value>
401-
</data>
402-
<data name="net_http_libcurl_clientcerts_notsupported_os" xml:space="preserve">
403-
<value>The handler does not support client authentication certificates on this operating system. Consider using System.Net.Http.SocketsHttpHandler.</value>
404-
</data>
405-
<data name="net_http_libcurl_revocation_notsupported_sslbackend" xml:space="preserve">
406-
<value>The handler does not support changing revocation settings with this combination of libcurl ({0}) and its SSL backend ("{1}"). An SSL backend based on "{2}" is required. Consider using System.Net.Http.SocketsHttpHandler.</value>
407-
</data>
408387
<data name="net_http_feature_requires_Windows10Version1607" xml:space="preserve">
409388
<value>Using this feature requires Windows 10 Version 1607.</value>
410389
</data>
@@ -543,4 +522,4 @@
543522
<data name="net_http_invalid_header_name" xml:space="preserve">
544523
<value>Received an invalid header name: '{0}'.</value>
545524
</data>
546-
</root>
525+
</root>

‎src/System.Net.Http/src/System/Net/Http/DiagnosticsHandlerLoggingStrings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace System.Net.Http
66
{
77
/// <summary>
8-
/// Defines names of DiagnosticListener and Write events for WinHttpHandler, CurlHandler, and HttpHandlerToFilter.
8+
/// Defines names of DiagnosticListener and Write events for DiagnosticHandler
99
/// </summary>
1010
internal static class DiagnosticsHandlerLoggingStrings
1111
{

‎src/System.Net.Http/src/System/Net/Http/HttpClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,8 @@ private void HandleFinishSendAsyncCleanup(CancellationTokenSource cts, bool disp
604604
// left for the finalizer to handle, or the developer can explicitly dispose of the
605605
// content when they're done with it. But it allows request content to be reused,
606606
// and more importantly it enables handlers that allow receiving of the response before
607-
// fully sending the request. Prior to this change, a handler like CurlHandler would
608-
// fail trying to access certain sites, if the site sent its response before it had
607+
// fully sending the request. Prior to this change, a handler that supported duplex communication
608+
// would fail trying to access certain sites, if the site sent its response before it had
609609
// completely received the request: CurlHandler might then find that the request content
610610
// was disposed of while it still needed to read from it.
611611
}

‎src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private HttpMessageHandler SetupHandlerChain()
305305

306306
if (settings._allowAutoRedirect)
307307
{
308-
// Just as with WinHttpHandler and CurlHandler, for security reasons, we do not support authentication on redirects
308+
// Just as with WinHttpHandler, for security reasons, we do not support authentication on redirects
309309
// if the credential is anything other than a CredentialCache.
310310
// We allow credentials in a CredentialCache since they are specifically tied to URIs.
311311
HttpMessageHandler redirectHandler =

‎src/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs

+1-16
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,6 @@ public void SendAsync_ExpectedDiagnosticExceptionActivityLogging()
751751
[Fact]
752752
public void SendAsync_ExpectedDiagnosticSynchronousExceptionActivityLogging()
753753
{
754-
if (IsCurlHandler)
755-
{
756-
// The only way to throw a synchronous exception for CurlHandler through
757-
// DiagnosticHandler is when the Request uri scheme is Https, and the
758-
// backend doesn't support SSL.
759-
return;
760-
}
761-
762754
RemoteExecutor.Invoke((useSocketsHttpHandlerString, useHttp2String) =>
763755
{
764756
bool exceptionLogged = false;
@@ -1135,14 +1127,7 @@ public void SendAsync_NullRequest_ThrowsArgumentNullException()
11351127
// Getting the Task first from the .SendAsync() call also tests
11361128
// that the exception comes from the async Task path.
11371129
Task t = handler.SendAsync(null);
1138-
if (PlatformDetection.IsInAppContainer)
1139-
{
1140-
await Assert.ThrowsAsync<HttpRequestException>(() => t);
1141-
}
1142-
else
1143-
{
1144-
await Assert.ThrowsAsync<ArgumentNullException>(() => t);
1145-
}
1130+
await Assert.ThrowsAsync<ArgumentNullException>(() => t);
11461131
}
11471132
}
11481133

‎src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.AcceptAllCerts.cs

-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol,
4444
// Issue: #22089
4545
requestOnlyThisProtocol |= PlatformDetection.IsMacOsHighSierraOrHigher && acceptedProtocol == SslProtocols.Tls;
4646

47-
if (PlatformDetection.IsMacOsCatalinaOrHigher && acceptedProtocol == SslProtocols.Tls && IsCurlHandler)
48-
{
49-
// Issue: #39989
50-
// When the server uses SslProtocols.Tls, on MacOS, SecureTransport ends up picking a cipher suite
51-
// for TLS1.2, even though server said it was only using TLS1.0. LibreSsl throws error that
52-
// wrong cipher is used for TLS1.0.
53-
throw new SkipTestException("OSX may pick future cipher suites when asked for TLS1.0");
54-
}
55-
5647
using (HttpClientHandler handler = CreateHttpClientHandler())
5748
using (HttpClient client = CreateHttpClient(handler))
5849
{

‎src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Authentication.cs

+13-67
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ public async Task HttpClientHandler_Authentication_Succeeds(string authenticateH
5050
return;
5151
}
5252

53-
// Digest authentication does not work with domain credentials on CurlHandler. This is blocked by the behavior of LibCurl.
54-
NetworkCredential credentials = (IsCurlHandler && authenticateHeader.ToLowerInvariant().Contains("digest")) ?
55-
s_credentialsNoDomain :
56-
s_credentials;
57-
5853
var options = new LoopbackServer.Options { Domain = Domain, Username = Username, Password = Password };
5954
await LoopbackServer.CreateServerAsync(async (server, url) =>
6055
{
@@ -65,7 +60,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
6560
server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.Unauthorized, serverAuthenticateHeader);
6661

6762
await TestHelper.WhenAllCompletedOrAnyFailedWithTimeout(TestHelper.PassingTestTimeoutMilliseconds,
68-
CreateAndValidateRequest(handler, url, result ? HttpStatusCode.OK : HttpStatusCode.Unauthorized, credentials), serverTask);
63+
CreateAndValidateRequest(handler, url, result ? HttpStatusCode.OK : HttpStatusCode.Unauthorized, s_credentials), serverTask);
6964
}, options);
7065
}
7166

@@ -90,7 +85,7 @@ public async Task HttpClientHandler_MultipleAuthenticateHeaders_WithSameAuth_Suc
9085
[InlineData("WWW-Authenticate: Digest realm=\"hello\", nonce=\"hello\", algorithm=MD5\r\nWWW-Authenticate: Basic realm=\"hello\"\r\n")]
9186
public async Task HttpClientHandler_MultipleAuthenticateHeaders_Succeeds(string authenticateHeader)
9287
{
93-
if (PlatformDetection.IsWindowsNanoServer || (IsCurlHandler && authenticateHeader.Contains("Digest")))
88+
if (PlatformDetection.IsWindowsNanoServer)
9489
{
9590
// TODO: #28065: Fix failing authentication test cases on different httpclienthandlers.
9691
return;
@@ -110,7 +105,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) =>
110105
[InlineData("WWW-Authenticate: Basic realm=\"hello\"\r\nWWW-Authenticate: Digest realm=\"hello\", nonce=\"hello\", algorithm=MD5\r\nWWW-Authenticate: NTLM\r\n", "Digest", "Negotiate")]
111106
public async Task HttpClientHandler_MultipleAuthenticateHeaders_PicksSupported(string authenticateHeader, string supportedAuth, string unsupportedAuth)
112107
{
113-
if (PlatformDetection.IsWindowsNanoServer || (IsCurlHandler && authenticateHeader.Contains("Digest")))
108+
if (PlatformDetection.IsWindowsNanoServer)
114109
{
115110
// TODO: #28065: Fix failing authentication test cases on different httpclienthandlers.
116111
return;
@@ -159,13 +154,9 @@ public static IEnumerable<object[]> Authentication_TestData()
159154
yield return new object[] { $"Basic realm=\"testrealm\", " +
160155
$"Digest realm=\"testrealm\", nonce=\"{Convert.ToBase64String(Encoding.UTF8.GetBytes($"{DateTimeOffset.UtcNow}:XMh;z+$5|`i6Hx}}"))}\", algorithm=MD5", true };
161156

162-
if (PlatformDetection.IsNetCore)
163-
{
164-
// TODO: #28060: Fix failing authentication test cases on Framework run.
165-
yield return new object[] { "Basic something, Digest something", false };
166-
yield return new object[] { $"Digest realm=\"testrealm\", nonce=\"testnonce\", algorithm=MD5 " +
167-
$"Basic realm=\"testrealm\"", false };
168-
}
157+
yield return new object[] { "Basic something, Digest something", false };
158+
yield return new object[] { $"Digest realm=\"testrealm\", nonce=\"testnonce\", algorithm=MD5 " +
159+
$"Basic realm=\"testrealm\"", false };
169160
}
170161

171162
[Theory]
@@ -177,13 +168,6 @@ public static IEnumerable<object[]> Authentication_TestData()
177168
[InlineData("Negotiate")]
178169
public async Task PreAuthenticate_NoPreviousAuthenticatedRequests_NoCredentialsSent(string credCacheScheme)
179170
{
180-
if (IsCurlHandler && credCacheScheme != null)
181-
{
182-
// When provided with a credential that targets just one auth scheme,
183-
// libcurl will often proactively send an auth header.
184-
return;
185-
}
186-
187171
const int NumRequests = 3;
188172
await LoopbackServer.CreateClientAndServerAsync(async uri =>
189173
{
@@ -226,13 +210,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
226210
[InlineData("Basic", "WWW-Authenticate: Basic realm=\"hello\"\r\n")]
227211
public async Task PreAuthenticate_FirstRequestNoHeaderAndAuthenticates_SecondRequestPreauthenticates(string credCacheScheme, string authResponse)
228212
{
229-
if (IsCurlHandler && credCacheScheme != null)
230-
{
231-
// When provided with a credential that targets just one auth scheme,
232-
// libcurl will often proactively send an auth header.
233-
return;
234-
}
235-
236213
await LoopbackServer.CreateClientAndServerAsync(async uri =>
237214
{
238215
using (HttpClientHandler handler = CreateHttpClientHandler())
@@ -439,13 +416,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
439416
// Third request, contains Basic auth header but challenges anyway
440417
headers = headers = await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.Unauthorized, "WWW-Authenticate: Basic realm=\"hello\"\r\n");
441418
Assert.Contains(headers, header => header.Contains("Authorization"));
442-
443-
if (IsNetfxHandler)
444-
{
445-
// For some reason, netfx tries one more time.
446-
headers = headers = await server.AcceptConnectionSendResponseAndCloseAsync(HttpStatusCode.Unauthorized, "WWW-Authenticate: Basic realm=\"hello\"\r\n");
447-
Assert.Contains(headers, header => header.Contains("Authorization"));
448-
}
449419
});
450420
}
451421

@@ -458,13 +428,6 @@ public async Task PreAuthenticate_SuccessfulBasic_ThenDigestChallenged()
458428
return;
459429
}
460430

461-
if (IsCurlHandler)
462-
{
463-
// When provided with a credential that targets just one auth scheme,
464-
// libcurl will often proactively send an auth header.
465-
return;
466-
}
467-
468431
await LoopbackServer.CreateClientAndServerAsync(async uri =>
469432
{
470433
using (HttpClientHandler handler = CreateHttpClientHandler())
@@ -503,16 +466,14 @@ public static IEnumerable<object[]> ServerUsesWindowsAuthentication_MemberData()
503466
string server = Configuration.Http.WindowsServerHttpHost;
504467
string authEndPoint = "showidentity.ashx";
505468

506-
yield return new object[] { $"http://{server}/test/auth/ntlm/{authEndPoint}", false };
507-
yield return new object[] { $"https://{server}/test/auth/ntlm/{authEndPoint}", false };
469+
yield return new object[] { $"http://{server}/test/auth/ntlm/{authEndPoint}" };
470+
yield return new object[] { $"https://{server}/test/auth/ntlm/{authEndPoint}" };
508471

509-
// Curlhandler (due to libcurl bug) cannot do Negotiate (SPNEGO) Kerberos to NTLM fallback.
510-
yield return new object[] { $"http://{server}/test/auth/negotiate/{authEndPoint}", true };
511-
yield return new object[] { $"https://{server}/test/auth/negotiate/{authEndPoint}", true };
472+
yield return new object[] { $"http://{server}/test/auth/negotiate/{authEndPoint}" };
473+
yield return new object[] { $"https://{server}/test/auth/negotiate/{authEndPoint}" };
512474

513475
// Server requires TLS channel binding token (cbt) with NTLM authentication.
514-
// CurlHandler (due to libcurl bug) cannot do NTLM authentication with cbt.
515-
yield return new object[] { $"https://{server}/test/auth/ntlm-epa/{authEndPoint}", true };
476+
yield return new object[] { $"https://{server}/test/auth/ntlm-epa/{authEndPoint}" };
516477
}
517478

518479
private static bool IsNtlmInstalled => Capability.IsNtlmInstalled();
@@ -575,11 +536,6 @@ public async Task Proxy_DomainJoinedProxyServerUsesKerberos_Success(Uri server)
575536
[ConditionalFact(nameof(IsDomainJoinedServerAvailable))]
576537
public async Task Credentials_DomainJoinedServerUsesKerberos_Success()
577538
{
578-
if (IsCurlHandler)
579-
{
580-
throw new SkipTestException("Skipping test on CurlHandler (libCurl)");
581-
}
582-
583539
using (HttpClientHandler handler = CreateHttpClientHandler())
584540
using (HttpClient client = CreateHttpClient(handler))
585541
{
@@ -598,7 +554,7 @@ public async Task Credentials_DomainJoinedServerUsesKerberos_Success()
598554
[ConditionalFact(nameof(IsDomainJoinedServerAvailable))]
599555
public async Task Credentials_DomainJoinedServerUsesKerberos_UseIpAddressAndHostHeader_Success()
600556
{
601-
if (IsCurlHandler || IsWinHttpHandler)
557+
if (IsWinHttpHandler)
602558
{
603559
throw new SkipTestException("Skipping test on platform handlers (CurlHandler, WinHttpHandler)");
604560
}
@@ -628,13 +584,8 @@ public async Task Credentials_DomainJoinedServerUsesKerberos_UseIpAddressAndHost
628584

629585
[ConditionalTheory(nameof(IsNtlmInstalled), nameof(IsWindowsServerAvailable))]
630586
[MemberData(nameof(ServerUsesWindowsAuthentication_MemberData))]
631-
public async Task Credentials_ServerUsesWindowsAuthentication_Success(string server, bool skipOnCurlHandler)
587+
public async Task Credentials_ServerUsesWindowsAuthentication_Success(string server)
632588
{
633-
if (IsCurlHandler && skipOnCurlHandler)
634-
{
635-
throw new SkipTestException("CurlHandler (libCurl) doesn't handle Negotiate with NTLM fallback nor CBT");
636-
}
637-
638589
using (HttpClientHandler handler = CreateHttpClientHandler())
639590
using (HttpClient client = CreateHttpClient(handler))
640591
{
@@ -656,11 +607,6 @@ public async Task Credentials_ServerUsesWindowsAuthentication_Success(string ser
656607
[InlineData("Negotiate")]
657608
public async Task Credentials_ServerChallengesWithWindowsAuth_ClientSendsWindowsAuthHeader(string authScheme)
658609
{
659-
if (authScheme == "Negotiate" && IsCurlHandler)
660-
{
661-
throw new SkipTestException("CurlHandler (libCurl) doesn't handle Negotiate with NTLM fallback");
662-
}
663-
664610
await LoopbackServerFactory.CreateClientAndServerAsync(
665611
async uri =>
666612
{

0 commit comments

Comments
 (0)
Please sign in to comment.