@@ -9,6 +9,26 @@ namespace Refit;
99/// <summary>Reflection-based request builder that turns Refit interface calls into HTTP requests.</summary>
1010internal partial class RequestBuilderImplementation
1111{
12+ /// <summary>Gets the cancellation token declared by the interface method, if any.</summary>
13+ /// <param name="restMethod">The rest method being invoked.</param>
14+ /// <param name="paramList">The argument values for the call.</param>
15+ /// <returns>The method's cancellation token, or <see cref="CancellationToken.None"/>.</returns>
16+ internal static CancellationToken GetMethodCancellationToken (
17+ RestMethodInfoInternal restMethod ,
18+ object [ ] paramList ) =>
19+ restMethod . CancellationToken is not null
20+ ? GetCancellationToken ( paramList )
21+ : CancellationToken . None ;
22+
23+ /// <summary>Determines whether the request body should be buffered before sending.</summary>
24+ /// <param name="restMethod">The rest method being invoked.</param>
25+ /// <param name="request">The built request message.</param>
26+ /// <returns><see langword="true"/> if the body should be buffered; otherwise <see langword="false"/>.</returns>
27+ internal static bool IsBodyBuffered (
28+ RestMethodInfoInternal restMethod ,
29+ HttpRequestMessage request ) =>
30+ ( restMethod . BodyParameterInfo ? . Item2 ?? false ) && request . Content is not null ;
31+
1232 /// <summary>Builds and streams the response for a method returning an asynchronous sequence.</summary>
1333 /// <typeparam name="T">The element type yielded to the caller.</typeparam>
1434 /// <param name="client">The HTTP client to send with.</param>
@@ -53,31 +73,11 @@ internal partial class RequestBuilderImplementation
5373 }
5474 }
5575
56- /// <summary>Gets the cancellation token declared by the interface method, if any.</summary>
57- /// <param name="restMethod">The rest method being invoked.</param>
58- /// <param name="paramList">The argument values for the call.</param>
59- /// <returns>The method's cancellation token, or <see cref="CancellationToken.None"/>.</returns>
60- private static CancellationToken GetMethodCancellationToken (
61- RestMethodInfoInternal restMethod ,
62- object [ ] paramList ) =>
63- restMethod . CancellationToken is not null
64- ? GetCancellationToken ( paramList )
65- : CancellationToken . None ;
66-
67- /// <summary>Determines whether the request body should be buffered before sending.</summary>
68- /// <param name="restMethod">The rest method being invoked.</param>
69- /// <param name="request">The built request message.</param>
70- /// <returns><see langword="true"/> if the body should be buffered; otherwise <see langword="false"/>.</returns>
71- private static bool IsBodyBuffered (
72- RestMethodInfoInternal restMethod ,
73- HttpRequestMessage request ) =>
74- ( restMethod . BodyParameterInfo ? . Item2 ?? false ) && request . Content is not null ;
75-
7676 /// <summary>Builds a delegate that constructs and returns the request for a <c>Task<HttpRequestMessage></c> method.</summary>
7777 /// <param name="restMethod">The rest method to build a delegate for.</param>
7878 /// <returns>A delegate that returns a task producing the built request without sending it.</returns>
7979 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
80- private Func < HttpClient , object [ ] , object ? > BuildRequestMessageFuncForMethod (
80+ internal Func < HttpClient , object [ ] , object ? > BuildRequestMessageFuncForMethod (
8181 RestMethodInfoInternal restMethod ) =>
8282 ( client , paramList ) => BuildRequestMessageWithoutSendingAsync ( client , restMethod , paramList ) ;
8383
@@ -90,7 +90,7 @@ private static bool IsBodyBuffered(
9090 /// logging, or manual dispatch. Any configured async authorization token getter runs at dispatch time and is
9191 /// therefore not applied to a request obtained this way.</remarks>
9292 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
93- private Task < HttpRequestMessage > BuildRequestMessageWithoutSendingAsync (
93+ internal Task < HttpRequestMessage > BuildRequestMessageWithoutSendingAsync (
9494 HttpClient client ,
9595 RestMethodInfoInternal restMethod ,
9696 object [ ] paramList )
@@ -113,7 +113,7 @@ private Task<HttpRequestMessage> BuildRequestMessageWithoutSendingAsync(
113113 /// <param name="cancellationToken">A token to cancel the request.</param>
114114 /// <returns>A task that completes when the request finishes.</returns>
115115 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
116- private async Task ExecuteVoidRequestAsync (
116+ internal async Task ExecuteVoidRequestAsync (
117117 HttpClient client ,
118118 RestMethodInfoInternal restMethod ,
119119 object [ ] paramList ,
@@ -154,7 +154,7 @@ await RequestExecutionHelpers.SendVoidAsync(
154154 "SST2307:Generic method type parameters should be inferable from the parameters" ,
155155 Justification = "Type parameter intentionally specified explicitly by callers." ) ]
156156 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
157- private async Task < T ? > ExecuteRequestAsync < T , TBody > (
157+ internal async Task < T ? > ExecuteRequestAsync < T , TBody > (
158158 HttpClient client ,
159159 RestMethodInfoInternal restMethod ,
160160 object [ ] paramList ,
@@ -192,7 +192,7 @@ await RequestExecutionHelpers.SendVoidAsync(
192192 Justification = "Type parameter intentionally specified explicitly by callers." ) ]
193193 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
194194 [ ExcludeFromCodeCoverage ]
195- private async IAsyncEnumerable < T ? > ExecuteAsyncEnumerableRequestAsync < T > (
195+ internal async IAsyncEnumerable < T ? > ExecuteAsyncEnumerableRequestAsync < T > (
196196 HttpClient client ,
197197 RestMethodInfoInternal restMethod ,
198198 object [ ] paramList ,
@@ -218,7 +218,7 @@ await RequestExecutionHelpers.SendVoidAsync(
218218 "SST2307:Generic method type parameters should be inferable from the parameters" ,
219219 Justification = "Type parameter intentionally specified explicitly by callers." ) ]
220220 [ RequiresDynamicCode ( "Serializing a body by runtime Type requires runtime generic method instantiation." ) ]
221- private Func < HttpClient , CancellationToken , object [ ] , Task < T ? > > BuildCancellableTaskFuncForMethod < T , TBody > (
221+ internal Func < HttpClient , CancellationToken , object [ ] , Task < T ? > > BuildCancellableTaskFuncForMethod < T , TBody > (
222222 RestMethodInfoInternal restMethod ) =>
223223 async ( client , ct , paramList ) =>
224224 {
@@ -254,7 +254,7 @@ await RequestExecutionHelpers.SendVoidAsync(
254254 "Design" ,
255255 "SST2307:Generic method type parameters should be inferable from the parameters" ,
256256 Justification = "Type parameter intentionally specified explicitly by callers." ) ]
257- private Task < T ? > SendAndProcessResponseAsync < T , TBody > (
257+ internal Task < T ? > SendAndProcessResponseAsync < T , TBody > (
258258 HttpClient client ,
259259 RestMethodInfoInternal restMethod ,
260260 HttpRequestMessage request ,
0 commit comments