mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Don't reuse http messages
This commit is contained in:
parent
91f717a25d
commit
ff55bfec9f
@ -53,10 +53,21 @@ namespace Wabbajack.Common.Http
|
|||||||
retries++;
|
retries++;
|
||||||
Utils.Log($"Http Connect error to {msg.RequestUri} retry {retries}");
|
Utils.Log($"Http Connect error to {msg.RequestUri} retry {retries}");
|
||||||
await Task.Delay(100 * retries);
|
await Task.Delay(100 * retries);
|
||||||
|
msg = CloneMessage(msg);
|
||||||
goto TOP;
|
goto TOP;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HttpRequestMessage CloneMessage(HttpRequestMessage msg)
|
||||||
|
{
|
||||||
|
var new_message = new HttpRequestMessage(msg.Method, msg.RequestUri);
|
||||||
|
foreach (var header in msg.Headers)
|
||||||
|
new_message.Headers.Add(header.Key, header.Value);
|
||||||
|
new_message.Content = msg.Content;
|
||||||
|
return new_message;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
Wabbajack.Test/HttpClientTests.cs
Normal file
18
Wabbajack.Test/HttpClientTests.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace Wabbajack.Test
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class HttpClientTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public async Task DoesntReuseHttpMessages()
|
||||||
|
{
|
||||||
|
var client = new Common.Http.Client();
|
||||||
|
// If we reuse the HTTP message this will throw a invalid operation exception
|
||||||
|
await Assert.ThrowsExceptionAsync<HttpRequestException>(async () => await client.GetAsync("http://blerg.blaz.bloz.buz"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user