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); }
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}"); }
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) { } }