Skip to content

Commit 407cf39

Browse files
authored
Updating httpClient to not follow redirects with EnableForwardingHttpRequest is true (#8373)
1 parent 101ef66 commit 407cf39

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/WebJobs.Script/Workers/Http/DefaultHttpWorkerService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class DefaultHttpWorkerService : IHttpWorkerService
2626
private readonly bool _enableRequestTracing;
2727

2828
public DefaultHttpWorkerService(IOptions<HttpWorkerOptions> httpWorkerOptions, ILoggerFactory loggerFactory, IEnvironment environment, IOptions<ScriptJobHostOptions> scriptHostOptions)
29-
: this(new HttpClient(), httpWorkerOptions, loggerFactory.CreateLogger<DefaultHttpWorkerService>(), environment, scriptHostOptions)
29+
: this(CreateHttpClient(httpWorkerOptions), httpWorkerOptions, loggerFactory.CreateLogger<DefaultHttpWorkerService>(), environment, scriptHostOptions)
3030
{
3131
}
3232

@@ -49,6 +49,13 @@ internal DefaultHttpWorkerService(HttpClient httpClient, IOptions<HttpWorkerOpti
4949
}
5050
}
5151

52+
private static HttpClient CreateHttpClient(IOptions<HttpWorkerOptions> httpWorkerOptions)
53+
{
54+
HttpClientHandler handler = new ();
55+
handler.AllowAutoRedirect = !httpWorkerOptions.Value.EnableForwardingHttpRequest;
56+
return new (handler);
57+
}
58+
5259
public Task InvokeAsync(ScriptInvocationContext scriptInvocationContext)
5360
{
5461
if (scriptInvocationContext.FunctionMetadata.IsHttpInAndOutFunction())

0 commit comments

Comments
 (0)