Skip to content

Commit de4a93e

Browse files
committed
Merge branch 'kendallb-feature/expect100-continue-support' into dev
2 parents 99f40bb + 18230ff commit de4a93e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/RestSharp/RestClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public RestClient(HttpMessageHandler handler, bool disposeHandler = true) : this
125125

126126
void ConfigureHttpClient(HttpClient httpClient) {
127127
if (Options.MaxTimeout > 0) httpClient.Timeout = TimeSpan.FromMilliseconds(Options.MaxTimeout);
128-
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(Options.UserAgent);
128+
if (httpClient.DefaultRequestHeaders.UserAgent.All(x => x.Product.Name != "RestSharp")) {
129+
httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(Options.UserAgent);
130+
}
131+
if (Options.Expect100Continue != null)
132+
httpClient.DefaultRequestHeaders.ExpectContinue = Options.Expect100Continue;
129133
}
130134

131135
void ConfigureHttpMessageHandler(HttpClientHandler handler) {

src/RestSharp/RestClientOptions.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,20 @@ public RestClientOptions(string baseUrl) : this(new Uri(Ensure.NotEmptyString(ba
7070
/// </summary>
7171
public X509CertificateCollection? ClientCertificates { get; set; }
7272

73-
public IWebProxy? Proxy { get; set; }
74-
public CacheControlHeaderValue? CachePolicy { get; set; }
75-
public bool FollowRedirects { get; set; } = true;
76-
public CookieContainer? CookieContainer { get; set; }
77-
public string UserAgent { get; set; } = DefaultUserAgent;
78-
73+
public IWebProxy? Proxy { get; set; }
74+
public CacheControlHeaderValue? CachePolicy { get; set; }
75+
public bool FollowRedirects { get; set; } = true;
76+
public bool? Expect100Continue { get; set; } = null;
77+
public CookieContainer? CookieContainer { get; set; }
78+
public string UserAgent { get; set; } = DefaultUserAgent;
79+
7980
/// <summary>
8081
/// Maximum request duration in milliseconds. When the request timeout is specified using <seealso cref="RestRequest.Timeout"/>,
8182
/// the lowest value between the client timeout and request timeout will be used.
8283
/// </summary>
83-
public int MaxTimeout { get; set; }
84-
85-
public Encoding Encoding { get; set; } = Encoding.UTF8;
84+
public int MaxTimeout { get; set; }
85+
86+
public Encoding Encoding { get; set; } = Encoding.UTF8;
8687

8788
[Obsolete("Use MaxTimeout instead")]
8889
public int Timeout {
@@ -128,4 +129,4 @@ public int Timeout {
128129
/// This properly allows to override the default behavior.
129130
/// </summary>
130131
public bool AllowMultipleDefaultParametersWithSameName { get; set; }
131-
}
132+
}

0 commit comments

Comments
 (0)