Skip to content

Custom Handler Proxying #11035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

Custom Handler Proxying #11035

wants to merge 15 commits into from

Conversation

satvu
Copy link
Member

@satvu satvu commented Apr 25, 2025

Issue describing the changes in this PR

resolves #11025

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR - TODO
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

@satvu satvu marked this pull request as ready for review April 28, 2025 20:17
@satvu satvu requested a review from a team as a code owner April 28, 2025 20:17
@satvu satvu requested a review from fabiocav April 28, 2025 20:17
_httpProxyService.StartForwarding(scriptInvocationContext, _destinationPrefix);

await _httpProxyService.EnsureSuccessfulForwardingAsync(scriptInvocationContext);
scriptInvocationContext.ResultSource.SetResult(_successfulInvocationResult);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the downstream code updates this _successfulInvocationResult instance? I see we use a shared instance for all invocations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the downstream code does not. This value is set to allow the function invocation to continue, but its value is never used (similar to how http proxying flows). We ignore the function invocation result at this step so that the actual response just flows through.

@@ -289,6 +289,8 @@ public static IHostBuilder AddScriptHostCore(this IHostBuilder builder, ScriptAp
// Core WebJobs/Script Host services
services.AddSingleton<ScriptHost>();

services.AddSingleton<IHttpProxyService, DefaultHttpProxyService>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be conditionally registered? Only when custom handlers is enabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the cleanup and refactor, this service will also be used for HTTP Proxying for worker http streaming. Information about streaming support/capabilities won't be known until there is a worker init response (which occurs much later than this stage).

@satvu satvu requested review from kshyju and liliankasem April 29, 2025 23:19
@satvu satvu force-pushed the satvu/custom-handler-streaming branch from 6043724 to a05018b Compare May 14, 2025 00:46
};

_destinationPrefix = new UriBuilder(WorkerConstants.HttpScheme, WorkerConstants.HostName, _httpWorkerOptions.Port).Uri;
_userAgentString = $"{HttpWorkerConstants.UserAgentHeaderValue}/{ScriptHost.Version}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this ever get set outside of the ctor? Could this be a const? It doesnt look like its made up of anything that would require it to be init in here no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't get set outside of the ctor, but ScriptHost.Version isn't a constant so this can't be init as a constant outside of the ctor at the top of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update custom handlers to proxy requests to custom workers
3 participants