@@ -16,22 +16,44 @@ internal class RequestQueue
1616 Marshal . SizeOf < HttpApiTypes . HTTP_BINDING_INFO > ( ) ;
1717
1818 private readonly RequestQueueMode _mode ;
19- private readonly UrlGroup _urlGroup ;
2019 private readonly ILogger _logger ;
2120 private bool _disposed ;
2221
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+
2336 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 )
2441 {
2542 _mode = mode ;
26- _urlGroup = urlGroup ;
43+ UrlGroup = urlGroup ;
2744 _logger = logger ;
2845
2946 var flags = HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . None ;
3047 Created = true ;
48+
3149 if ( _mode == RequestQueueMode . Attach )
3250 {
3351 flags = HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . OpenExisting ;
3452 Created = false ;
53+ if ( receiver )
54+ {
55+ flags |= HttpApiTypes . HTTP_CREATE_REQUEST_QUEUE_FLAG . Delegation ;
56+ }
3557 }
3658
3759 var statusCode = HttpApi . HttpCreateRequestQueue (
@@ -54,7 +76,7 @@ internal RequestQueue(UrlGroup urlGroup, string requestQueueName, RequestQueueMo
5476 out requestQueueHandle ) ;
5577 }
5678
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 )
5880 {
5981 throw new HttpSysException ( ( int ) statusCode , $ "Failed to attach to the given request queue '{ requestQueueName } ', the queue could not be found.") ;
6082 }
@@ -95,6 +117,8 @@ internal RequestQueue(UrlGroup urlGroup, string requestQueueName, RequestQueueMo
95117 internal SafeHandle Handle { get ; }
96118 internal ThreadPoolBoundHandle BoundHandle { get ; }
97119
120+ internal UrlGroup UrlGroup { get ; }
121+
98122 internal unsafe void AttachToUrlGroup ( )
99123 {
100124 Debug . Assert ( Created ) ;
@@ -108,7 +132,7 @@ internal unsafe void AttachToUrlGroup()
108132
109133 var infoptr = new IntPtr ( & info ) ;
110134
111- _urlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
135+ UrlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
112136 infoptr , ( uint ) BindingInfoSize ) ;
113137 }
114138
@@ -128,7 +152,7 @@ internal unsafe void DetachFromUrlGroup()
128152
129153 var infoptr = new IntPtr ( & info ) ;
130154
131- _urlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
155+ UrlGroup . SetProperty ( HttpApiTypes . HTTP_SERVER_PROPERTY . HttpServerBindingProperty ,
132156 infoptr , ( uint ) BindingInfoSize , throwOnError : false ) ;
133157 }
134158
0 commit comments