예제 #1
0
        public async Task <QueueRequest> Convert(HttpRequestMessage message)
        {
            var emptyBody = message.Method == HttpMethod.Get || message.Method == HttpMethod.Delete;

            if (emptyBody && message.Content != null)
            {
                _log.LogWarning($"uri: {message.RequestUri} method not available body. But body is set");
            }

            var query = message.RequestUri.ParseQueryString();

            var request = new QueueRequest
            {
                Body        = !emptyBody ? await message.Content.ReadAsStreamAsync() : Stream.Null,
                ContentType = message.Content?.Headers?.ContentType?.ToString() ?? QueueConsts.DefaultContentType,
                IsHttps     = false,
                Method      = message.Method.ToString(),
                Protocol    = message.RequestUri.Scheme,
                QueryString = new QueryString(message.RequestUri.Query),
                Query       = new QueryCollection(query.AllKeys.GroupBy(x => x).ToDictionary(x => x.Key, x => new StringValues(query[x.Key]))),
                Path        = message.RequestUri.AbsolutePath,
                Host        = new HostString(message.RequestUri.Host),
                Scheme      = message.RequestUri.Scheme,
                PathBase    = PathString.Empty
            };

            request.ContentLength = request.Body.Length;
            AddHeaders(request.Headers, message.Headers);
            if (message.Content?.Headers != null)
            {
                AddHeaders(request.Headers, message.Content.Headers);
            }

            return(request);
        }
예제 #2
0
        /// <inheritdoc />
        public QueueContext(IFeatureCollection features, QueueResponse response, QueueRequest request)
        {
            Features      = features;
            QueueResponse = response;
            QueueRequest  = request;

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