Support HTTP request body in InvokeRecActionCommandHandler
Added logic to handle non-null `request.Body` in HTTP requests. Introduced a `StringContent` object to encapsulate the body content and assigned it to the `Content` property of the HTTP request. This ensures that the request body is included when sending data to the specified endpoint.
This commit is contained in:
parent
6f5409f528
commit
ff3908cdd2
@ -40,6 +40,12 @@ public class InvokeRecActionCommandHandler(
|
|||||||
.ToHttpMethod()
|
.ToHttpMethod()
|
||||||
.ToHttpRequestMessage(request.EndpointUri);
|
.ToHttpRequestMessage(request.EndpointUri);
|
||||||
|
|
||||||
|
if(request.Body is not null)
|
||||||
|
{
|
||||||
|
using var reqBody = new StringContent(request.Body);
|
||||||
|
httpReq.Content = reqBody;
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await http.SendAsync(httpReq, cancel);
|
using var response = await http.SendAsync(httpReq, cancel);
|
||||||
var body = await response.Content.ReadAsStringAsync(cancel);
|
var body = await response.Content.ReadAsStringAsync(cancel);
|
||||||
var headers = response.Headers.ToDictionary();
|
var headers = response.Headers.ToDictionary();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user