3.69Setting Additional Configuration on Redirect

Created on Aug 17, 2026~2 min read

When a request undergoes automatic redirection (for example, status codes such as 301, 302, 307, 308), the framework clones a new builder based on the current builder for the redirect request. If you need to perform additional processing on the new builder during redirection (for example, removing the cross-origin Authorization header, adjusting request headers, modifying the timeout, etc.), you can register a custom callback using the SetOnRedirect method.

cs
HttpRequestBuilder.Post("https://furion.net/")    .SetOnRedirect((originalBuilder, redirectBuilder) =>    {        // For example, remove the Authorization header on redirect        redirectBuilder.Headers?.Remove("Authorization");    });

Parameter description:

  • originalBuilder: The original builder before redirection (or the builder from the previous redirect), from which the original configuration can be read.
  • redirectBuilder: The cloned builder about to be used for the redirect; you can modify any of its properties.

Note: The SetOnRedirect method supports multiple calls, and each registered callback is executed in turn upon redirection.