Only send `Expect` header for `comm.httpPost` when payload is large (squashed PR #4188)
* BizHawk#4187 Add a method to the comm LUA library to allow setting ExpectContinue * Instead of exposing ExpectContinue set it automatically based on a threshold
This commit is contained in:
parent
6c6986d79e
commit
544b8007dc
|
@ -20,6 +20,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public int Timeout { get; set; }
|
||||
|
||||
public int ExpectContinueThreshold { get; set; } = 1024 * 1024; // 1MB
|
||||
|
||||
public HttpCommunication(Func<byte[]> takeScreenshotCallback, string getURL, string postURL)
|
||||
{
|
||||
_takeScreenshotCallback = takeScreenshotCallback;
|
||||
|
@ -30,10 +32,14 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public string ExecGet(string url = null) => Get(url ?? GetUrl).Result;
|
||||
|
||||
public string ExecPost(string url = null, string payload = "") => Post(
|
||||
url ?? PostUrl,
|
||||
new FormUrlEncodedContent(new Dictionary<string, string> { ["payload"] = payload })
|
||||
).Result;
|
||||
public string ExecPost(string url = null, string payload = "")
|
||||
{
|
||||
_client.DefaultRequestHeaders.ExpectContinue = payload.Length > ExpectContinueThreshold;
|
||||
return Post(
|
||||
url ?? PostUrl,
|
||||
new FormUrlEncodedContent(new Dictionary<string, string> { ["payload"] = payload })
|
||||
).Result;
|
||||
}
|
||||
|
||||
public async Task<string> Get(string url)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue