Skip to content

Commit 9e0e2b8

Browse files
committed
Add Accept header to requests
See https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_50_cat_api.html Remove Host property from CatNodes Add bytes_recovered and files_recovered to cat recovery Rename total_files and total_bytes to files_total and bytes_total, respectively Rename translog to translog_ops_recovered Rename translog_total to translog_ops Rename translog_percent to translog_ops_percent Closes #2012
1 parent f23e39d commit 9e0e2b8

File tree

13 files changed

+10606
-10581
lines changed

13 files changed

+10606
-10581
lines changed

Diff for: src/CodeGeneration/CodeGeneration.LowLevelClient/Views/ElasticLowLevelClient.Generated.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace Elasticsearch.Net
5151
}
5252
<text>@Raw(@"///<param name=""requestParameters"">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>")</text>
5353
<text>public @Raw(method.ReturnType) @(method.FullName)@(Raw(method.ReturnTypeGeneric))(@Raw(method.Arguments))
54-
where @method.CallTypeGeneric : class => this.@(requestMethod)@(Raw("<" + method.CallTypeGeneric +">"))(@method.HttpMethod, Url($"@(Raw(patchedUrl))"), @(method.Parts.Any(pp=>pp.Name == "body") ? "body" : "null"), _params(requestParameters@(method.Allow404 ? ", allow404: true" :"")@(Raw(url.StartsWith("_cat") ? ", contentType: \"text/plain\"" : ""))));
54+
where @method.CallTypeGeneric : class => this.@(requestMethod)@(Raw("<" + method.CallTypeGeneric +">"))(@method.HttpMethod, Url($"@(Raw(patchedUrl))"), @(method.Parts.Any(pp=>pp.Name == "body") ? "body" : "null"), _params(requestParameters@(method.Allow404 ? ", allow404: true" :"")@(Raw(url.StartsWith("_cat") ? ", contentType: \"text/plain\", accept: \"text/plain\"" : ""))));
5555
</text>
5656
}
5757
}

Diff for: src/Elasticsearch.Net/Configuration/RequestConfiguration.cs

+28-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elasticsearch.Net
66
{
7-
public interface IRequestConfiguration
7+
public interface IRequestConfiguration
88
{
99
/// <summary>
1010
/// The timeout for this specific request, takes precedence over the global timeout settings
@@ -17,10 +17,15 @@ public interface IRequestConfiguration
1717
TimeSpan? PingTimeout { get; set; }
1818

1919
/// <summary>
20-
/// Force a difference content type header on the request
20+
/// Force a different Content-Type header on the request
2121
/// </summary>
2222
string ContentType { get; set; }
23-
23+
24+
/// <summary>
25+
/// Force a different Accept header on the request
26+
/// </summary>
27+
string Accept { get; set; }
28+
2429
/// <summary>
2530
/// This will override whatever is set on the connection configuration or whatever default the connectionpool has.
2631
/// </summary>
@@ -32,13 +37,13 @@ public interface IRequestConfiguration
3237
Uri ForceNode { get; set; }
3338

3439
/// <summary>
35-
/// Forces no sniffing to occur on the request no matter what configuration is in place
40+
/// Forces no sniffing to occur on the request no matter what configuration is in place
3641
/// globally
3742
/// </summary>
3843
bool? DisableSniff { get; set; }
3944

4045
/// <summary>
41-
/// Under no circumstance do a ping before the actual call. If a node was previously dead a small ping with
46+
/// Under no circumstance do a ping before the actual call. If a node was previously dead a small ping with
4247
/// low connect timeout will be tried first in normal circumstances
4348
/// </summary>
4449
bool? DisablePing { get; set; }
@@ -70,6 +75,7 @@ public class RequestConfiguration : IRequestConfiguration
7075
public TimeSpan? RequestTimeout { get; set; }
7176
public TimeSpan? PingTimeout { get; set; }
7277
public string ContentType { get; set; }
78+
public string Accept { get; set; }
7379
public int? MaxRetries { get; set; }
7480
public Uri ForceNode { get; set; }
7581
public bool? DisableSniff { get; set; }
@@ -87,17 +93,19 @@ public class RequestConfigurationDescriptor : IRequestConfiguration
8793
TimeSpan? IRequestConfiguration.RequestTimeout { get; set; }
8894

8995
TimeSpan? IRequestConfiguration.PingTimeout { get; set; }
90-
96+
9197
string IRequestConfiguration.ContentType { get; set; }
92-
98+
99+
string IRequestConfiguration.Accept { get; set; }
100+
93101
int? IRequestConfiguration.MaxRetries { get; set; }
94-
102+
95103
Uri IRequestConfiguration.ForceNode { get; set; }
96-
104+
97105
bool? IRequestConfiguration.DisableSniff { get; set; }
98-
106+
99107
bool? IRequestConfiguration.DisablePing { get; set; }
100-
108+
101109
IEnumerable<int> IRequestConfiguration.AllowedStatusCodes { get; set; }
102110

103111
BasicAuthenticationCredentials IRequestConfiguration.BasicAuthenticationCredentials { get; set; }
@@ -118,9 +126,15 @@ public RequestConfigurationDescriptor PingTimeout(TimeSpan pingTimeout)
118126
return this;
119127
}
120128

121-
public RequestConfigurationDescriptor AcceptContentType(string acceptContentTypeHeader)
129+
public RequestConfigurationDescriptor ContentType(string contentTypeHeader)
130+
{
131+
Self.ContentType = contentTypeHeader;
132+
return this;
133+
}
134+
135+
public RequestConfigurationDescriptor Accept(string acceptHeader)
122136
{
123-
Self.ContentType = acceptContentTypeHeader;
137+
Self.Accept = acceptHeader;
124138
return this;
125139
}
126140

@@ -179,4 +193,4 @@ public RequestConfigurationDescriptor EnableHttpPipelining(bool enable = true)
179193
return this;
180194
}
181195
}
182-
}
196+
}

Diff for: src/Elasticsearch.Net/Connection/HttpConnection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected virtual HttpWebRequest CreateWebRequest(RequestData requestData)
3636
{
3737
var request = (HttpWebRequest)WebRequest.Create(requestData.Uri);
3838

39-
request.Accept = requestData.ContentType;
39+
request.Accept = requestData.Accept;
4040
request.ContentType = requestData.ContentType;
4141

4242
request.MaximumResponseHeadersLength = -1;

0 commit comments

Comments
 (0)