コード例 #1
0
        public HttpRequestMessage GetProxyRequest(HttpContext context, IWMSRule matchedRule, Uri uri)
        {
            var requestMessage = _httpRequestMessageHandler.GenerateProxyRequest(context, uri);

            matchedRule.SetSessionToken(requestMessage);

            matchedRule.ChangeRequestUri(requestMessage, context);

            requestMessage.Headers.Host = _httpRequestMessageHandler.GetHeadersHost(requestMessage);

            return(requestMessage);
        }
コード例 #2
0
ファイル: WMSProxyManager.cs プロジェクト: yodeskir/wms-proxy
        public async Task ProxyRequest(HttpContext context, IWMSRule matchedRule)
        {
            var uri          = _contextHandler.GetRequestUri(context.Request);
            var proxyRequest = _wmsProxyRequestHandler.GetProxyRequest(context, matchedRule, uri);

            try
            {
                await _wmsProxy.ProxyTheRequest(context, proxyRequest, matchedRule);
            }
            catch (HttpRequestException ex)
            {
                context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
            }

            _logger.LogDebug($@"Original Url: {proxyRequest.RequestUri.AbsoluteUri}, Proxied Url: {uri}, StatusCode: {context.Response.StatusCode}");
        }
コード例 #3
0
        public async Task ProxyTheRequest(HttpContext context, HttpRequestMessage proxyRequest, IWMSRule proxyRule)
        {
            try
            {
                using (var responseMessage = await _httpClientWrapper.SendAsync(proxyRequest, context.RequestAborted))
                {
                    if (proxyRule.PreProcessResponse)
                    {
                        await _wmsMessageProcessor.PreProcess(context, responseMessage);
                    }

                    await proxyRule.ResponseModifier(responseMessage, context);
                }
            }
            catch (Exception ex) {
            }
        }