Simplify StringContent assignment in HTTP request
Refactored code to assign StringContent directly to httpReq.Content without a using block. Disposal of StringContent is now handled by HttpRequestMessage, improving code clarity and resource management.
This commit is contained in:
@@ -43,10 +43,7 @@ public class InvokeRecActionViewCommandHandler(
|
|||||||
.ToHttpRequestMessage(action.EndpointUri);
|
.ToHttpRequestMessage(action.EndpointUri);
|
||||||
|
|
||||||
if (action.Body is not null)
|
if (action.Body is not null)
|
||||||
{
|
httpReq.Content = new StringContent(action.Body);
|
||||||
using var reqBody = new StringContent(action.Body);
|
|
||||||
httpReq.Content = reqBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action.Headers is not null)
|
if (action.Headers is not null)
|
||||||
foreach (var header in action.Headers)
|
foreach (var header in action.Headers)
|
||||||
|
|||||||
Reference in New Issue
Block a user