From ed665ce1c843d91628e6a34e65a8f44810d64e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Mon, 20 Jan 2020 16:18:31 +0100 Subject: [PATCH] Fix reverse proxy sending content if there must be none --- Modules/GenHTTP.Modules.Core/Proxy/ReverseProxyProvider.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/GenHTTP.Modules.Core/Proxy/ReverseProxyProvider.cs b/Modules/GenHTTP.Modules.Core/Proxy/ReverseProxyProvider.cs index f95e5eb0..2db414e5 100644 --- a/Modules/GenHTTP.Modules.Core/Proxy/ReverseProxyProvider.cs +++ b/Modules/GenHTTP.Modules.Core/Proxy/ReverseProxyProvider.cs @@ -57,7 +57,7 @@ protected override IResponseBuilder HandleInternal(IRequest request) { var req = ConfigureRequest(request); - if (request.Content != null) + if ((request.Content != null) && CanSendBody(request)) { using (var inputStream = req.GetRequestStream()) { @@ -191,6 +191,11 @@ private bool HasBody(IRequest request, HttpWebResponse response) return !request.HasType(RequestMethod.HEAD) && (response.ContentType != null); } + private bool CanSendBody(IRequest request) + { + return (request.Method != RequestMethod.GET) && (request.Method != RequestMethod.HEAD); + } + private string RewriteLocation(string location, IRequest request) { if (location.StartsWith(Upstream))