Skip to content

Commit ca0ad58

Browse files
committed
Instead of exposing ExpectContinue set it automatically based on a threshold
1 parent 77be962 commit ca0ad58

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/BizHawk.Client.Common/Api/HttpCommunication.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class HttpCommunication
2020

2121
public int Timeout { get; set; }
2222

23-
public bool ExpectContinue { get; set; } = true;
23+
public int ExpectContinueThreshold { get; set; } = 1024 * 1024; // 1MB
2424

2525
public HttpCommunication(Func<byte[]> takeScreenshotCallback, string getURL, string postURL)
2626
{
@@ -32,10 +32,14 @@ public HttpCommunication(Func<byte[]> takeScreenshotCallback, string getURL, str
3232

3333
public string ExecGet(string url = null) => Get(url ?? GetUrl).Result;
3434

35-
public string ExecPost(string url = null, string payload = "") => Post(
36-
url ?? PostUrl,
37-
new FormUrlEncodedContent(new Dictionary<string, string> { ["payload"] = payload })
38-
).Result;
35+
public string ExecPost(string url = null, string payload = "")
36+
{
37+
_client.DefaultRequestHeaders.ExpectContinue = payload.Length > ExpectContinueThreshold;
38+
return Post(
39+
url ?? PostUrl,
40+
new FormUrlEncodedContent(new Dictionary<string, string> { ["payload"] = payload })
41+
).Result;
42+
}
3943

4044
public async Task<string> Get(string url)
4145
{
@@ -51,7 +55,6 @@ public async Task<string> Get(string url)
5155
public async Task<string> Post(string url, FormUrlEncodedContent content)
5256
{
5357
_client.DefaultRequestHeaders.ConnectionClose = true;
54-
_client.DefaultRequestHeaders.ExpectContinue = ExpectContinue;
5558
HttpResponseMessage response;
5659
try
5760
{

src/BizHawk.Client.Common/lua/CommonLibs/CommLuaLibrary.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,6 @@ public void HttpSetGetUrl(string url)
231231
APIs.Comm.HTTP.GetUrl = url;
232232
}
233233

234-
[LuaMethod("httpSetExpectContinue", "Set ExpectContinue boolean to an explicit value")]
235-
public void HttpSetExpectContinue(bool value)
236-
{
237-
CheckHttp();
238-
APIs.Comm.HTTP.ExpectContinue = value;
239-
}
240-
241234
[LuaMethod("httpGetPostUrl", "Gets HTTP POST URL")]
242235
public string HttpGetPostUrl()
243236
{
@@ -252,13 +245,6 @@ public string HttpGetGetUrl()
252245
return APIs.Comm.HTTP?.GetUrl;
253246
}
254247

255-
[LuaMethod("httpGetExpectContinue", "Get ExpectContinue value")]
256-
public bool HttpGetExpectContinue()
257-
{
258-
CheckHttp();
259-
return APIs.Comm.HTTP.ExpectContinue;
260-
}
261-
262248
private void CheckHttp()
263249
{
264250
if (APIs.Comm.HTTP == null)

0 commit comments

Comments
 (0)