@@ -16,22 +16,44 @@ internal class RequestQueue
16
16
Marshal . SizeOf < HttpApiTypes . HTTP_BINDING_INFO > ( ) ;
17
17
18
18
private readonly RequestQueueMode _mode ;
19
- private readonly UrlGroup _urlGroup ;
20
19
private readonly ILogger _logger ;
21
20
private bool _disposed ;
22
21
22
+ internal RequestQueue ( string requestQueueName , string urlPrefix , ILogger logger , bool receiver )
23
+ : this ( urlGroup : null , requestQueueName , RequestQueueMode . Attach , logger , receiver )
24
+ {
25
+ try
26
+ {
27
+ UrlGroup = new UrlGroup ( this , UrlPrefix . Create ( urlPrefix ) ) ;
28
+ }
29
+ catch
30
+ {
31
+ Dispose ( ) ;
32
+ throw ;
33
+ }
34
+ }
35
+
23
36
internal RequestQueue ( UrlGroup urlGroup , string requestQueueName , RequestQueueMode mode , ILogger logger )
37
+ : this ( urlGroup , requestQueueName , mode , logger , false )
38
+ { }
39
+
40
+ private RequestQueue ( UrlGroup urlGroup , string requestQueueName , RequestQueueMode mode , ILogger logger , bool receiver )
24
41
{
25
42
_mode = mode ;
26
- _urlGroup = urlGroup ;
43
+ UrlGroup = urlGroup ;
27
44
_logger = logger ;
28
45
29
46
var flags = HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . None ;
30
47
Created = true ;
48
+
31
49
if ( _mode == RequestQueueMode . Attach )
32
50
{
33
51
flags = HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . OpenExisting ;
34
52
Created = false ;
53
+ if ( receiver )
54
+ {
55
+ flags |= HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . Delegation ;
56
+ }
35
57
}
36
58
37
59
var statusCode = HttpApi . HttpCreateRequestQueue (
@@ -54,7 +76,7 @@ internal RequestQueue(UrlGroup urlGroup, string requestQueueName, RequestQueueMo
54
76
out requestQueueHandle ) ;
55
77
}
56
78
57
- if ( flags == HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . OpenExisting && statusCode == UnsafeNclNativeMethods . ErrorCodes . ERROR_FILE_NOT_FOUND )
79
+ if ( flags . HasFlag ( HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . OpenExisting ) && statusCode == UnsafeNclNativeMethods . ErrorCodes . ERROR_FILE_NOT_FOUND )
58
80
{
59
81
throw new HttpSysException ( ( int ) statusCode , $ "Failed to attach to the given request queue '{ requestQueueName } ', the queue could not be found.") ;
60
82
}
@@ -95,6 +117,8 @@ internal RequestQueue(UrlGroup urlGroup, string requestQueueName, RequestQueueMo
95
117
internal SafeHandle Handle { get ; }
96
118
internal ThreadPoolBoundHandle BoundHandle { get ; }
97
119
120
+ internal UrlGroup UrlGroup { get ; }
121
+
98
122
internal unsafe void AttachToUrlGroup ( )
99
123
{
100
124
Debug . Assert ( Created ) ;
@@ -108,7 +132,7 @@ internal unsafe void AttachToUrlGroup()
108
132
109
133
var infoptr = new IntPtr ( & info ) ;
110
134
111
- _urlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
135
+ UrlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
112
136
infoptr , ( uint ) BindingInfoSize ) ;
113
137
}
114
138
@@ -128,7 +152,7 @@ internal unsafe void DetachFromUrlGroup()
128
152
129
153
var infoptr = new IntPtr ( & info ) ;
130
154
131
- _urlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
155
+ UrlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
132
156
infoptr , ( uint ) BindingInfoSize , throwOnError : false ) ;
133
157
}
134
158
0 commit comments