File tree 1 file changed +40
-0
lines changed
test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
+
4
+ using System . Net ;
5
+ using System . Net . Sockets ;
6
+ using System . Threading . Tasks ;
7
+ using Microsoft . AspNetCore . Server . Kestrel . Core ;
8
+ using Microsoft . AspNetCore . Testing ;
9
+ using Microsoft . AspNetCore . Testing . xunit ;
10
+
11
+ namespace Microsoft . AspNetCore . Server . Kestrel . FunctionalTests
12
+ {
13
+ [ OSSkipCondition ( OperatingSystems . Windows , SkipReason = "Listening to open TCP socket and/or pipe handles is not supported on Windows." ) ]
14
+ public class ListenHandleTests
15
+ {
16
+ [ ConditionalFact ]
17
+ public async Task CanListenToOpenTcpSocketHandle ( )
18
+ {
19
+ using ( var listenSocket = new Socket ( AddressFamily . InterNetwork , SocketType . Stream , ProtocolType . Tcp ) )
20
+ {
21
+ listenSocket . Bind ( new IPEndPoint ( IPAddress . Loopback , 0 ) ) ;
22
+
23
+ using ( var server = new TestServer ( _ => Task . CompletedTask , new TestServiceContext ( ) , new ListenOptions ( ( ulong ) listenSocket . Handle ) ) )
24
+ {
25
+ using ( var connection = new TestConnection ( ( ( IPEndPoint ) listenSocket . LocalEndPoint ) . Port ) )
26
+ {
27
+ await connection . SendEmptyGet ( ) ;
28
+
29
+ await connection . Receive (
30
+ "HTTP/1.1 200 OK" ,
31
+ $ "Date: { server . Context . DateHeaderValue } ",
32
+ "Content-Length: 0" ,
33
+ "" ,
34
+ "" ) ;
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments