I want to send the exact same request more than once, for example:
HttpClient client = new HttpClient();
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, "http://example.com");
await client.SendAsync(req, HttpCompletionOption.ResponseContentRead);
await client.SendAsync(req, HttpCompletionOption.ResponseContentRead);
Sending the request for a second time will throw an exception with the message:
The request message was already sent. Cannot send the same request
message multiple times.
Is their a way to "clone" the request so that I can send again?
My real code has more variables set on the HttpRequestMessage
than in the example above, variables like headers and request method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…