Add support for custom headers in HTTP requests
Enhanced HTTP request handling by adding support for dynamically including custom headers from the `request.Headers` collection. Implemented a null check to ensure robustness and prevent null reference exceptions when processing headers. This change improves flexibility and customization of HTTP requests.
This commit is contained in:
parent
07afcf3aa2
commit
b78b3e43f4
@ -57,6 +57,10 @@ public class InvokeRecActionCommandHandler(
|
||||
);
|
||||
}
|
||||
|
||||
if (request.Headers is not null)
|
||||
foreach (var header in request.Headers)
|
||||
httpReq.Headers.Add(header.Key, header.Value);
|
||||
|
||||
using var response = await http.SendAsync(httpReq, cancel);
|
||||
var body = await response.Content.ReadAsStringAsync(cancel);
|
||||
var headers = response.Headers.ToDictionary();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user