3.81Getting the Request Builder or Request Message (Pre-flight Request)

Created on Aug 17, 2026~5 min read

In some cases, you may want to only obtain the HTTP request object itself without actually sending the request. For example: verifying in unit tests that the generated request matches expectations, obtaining the request builder and then manually modifying it further, or passing the request message to another system for execution.

For this purpose, when the return type of a method that sends an HTTP remote request is HttpRequestBuilder or HttpRequestMessage, the framework directly builds and returns that object, skipping the actual network transfer. Example:

cs
// Get the builder; you can continue fluent configuration and then send manuallyvar builder = await httpRemoteService.GetAsAsync<HttpRequestBuilder>("https://furion.net");	// Does not send the requestbuilder.WithHeader("X-Custom", "value");var httpResponseMessage = await httpRemoteService.SendAsync(builder);	// Initiates the network request// Get the HttpRequestMessage for assertions or external passingvar httpRequestMessage = await httpRemoteService.GetAsAsync<HttpRequestMessage>("https://furion.net");	// Does not send the requestAssert.Equal("https://furion.net/", httpRequestMessage.RequestUri?.ToString());

Use Cases

  • Pre-flight Check: before formally sending, inspect whether the generated request object matches expectations. After confirming that the URL, request headers, Token injection, etc. are all correct, send it manually or continue processing.
  • Unit testing: without simulating a network environment, directly verify that the generated HttpRequestMessage contains the correct parameters, headers, and authentication information.
  • Request object passing: pass the constructed HttpRequestMessage to other services, libraries, or processes for execution, achieving separation between request construction and request execution.
  • Hybrid programming: first complete most of the configuration via the builder or declarative approach (parameter mapping, Token injection, etc.), then obtain the builder, make minor dynamic modifications, and send manually — combining the simplicity of the declarative style with the flexibility of the imperative style.