Ejemplo n.º 1
0
        public DelegationRule CreateDelegationRule(string queueName, string uri)
        {
            var rule = new DelegationRule(queueName, uri, _logger);

            _queue.UrlGroup.SetDelegationProperty(rule.Queue);
            return(rule);
        }
Ejemplo n.º 2
0
        internal unsafe void Delegate(DelegationRule destination)
        {
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (Request.HasRequestBodyStarted)
            {
                throw new InvalidOperationException("This request cannot be delegated, the request body has already started.");
            }
            if (Response.HasStarted)
            {
                throw new InvalidOperationException("This request cannot be delegated, the response has already started.");
            }

            var source = Server.RequestQueue;

            uint statusCode;

            fixed(char *uriPointer = destination.UrlPrefix)
            {
                var property = new HttpApiTypes.HTTP_DELEGATE_REQUEST_PROPERTY_INFO()
                {
                    PropertyId         = HttpApiTypes.HTTP_DELEGATE_REQUEST_PROPERTY_ID.DelegateRequestDelegateUrlProperty,
                    PropertyInfo       = (IntPtr)uriPointer,
                    PropertyInfoLength = (uint)System.Text.Encoding.Unicode.GetByteCount(destination.UrlPrefix)
                };

                statusCode = HttpApi.HttpDelegateRequestEx(source.Handle,
                                                           destination.Queue.Handle,
                                                           Request.RequestId,
                                                           destination.Queue.UrlGroup.Id,
                                                           propertyInfoSetSize: 1,
                                                           &property);
            }

            if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
            {
                throw new HttpSysException((int)statusCode);
            }

            Response.MarkDelegated();
        }