Exemplo n.º 1
0
        public async Task <HttpContext> Create(byte[] bytes, IFeatureCollection features, bool needResponseStream)
        {
            var request = await _transform.Convert(bytes);

            if (request == null)
            {
                return(null);
            }

            request.Headers.TryGetValue(HeaderNames.Accept, out var acceptValues);
            var accept   = acceptValues.ToString();
            var response = new QueueResponse
            {
                ContentType = string.IsNullOrWhiteSpace(accept) ? QueueConsts.DefaultContentType : accept,
                StatusCode  = StatusCodes.Status200OK,
                Body        = needResponseStream ? Stream.Null : new MemoryStream()
            };

            _log.LogTrace($"Create queue context");
            var context = new QueueContext(features, response, request);

            _log.LogTrace("Create context created {uri}", request.GetDisplayUrl());

            return(context);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public QueueContext(IFeatureCollection features, QueueResponse response, QueueRequest request)
        {
            Features      = features;
            QueueResponse = response;
            QueueRequest  = request;

            QueueResponse.Initialize(this);
            QueueRequest.Initialize(this);
        }