@@ -36,6 +36,7 @@ public virtual TResponse Request<TResponse>(RequestData requestData)
36
36
{
37
37
int ? statusCode = null ;
38
38
IEnumerable < string > warnings = null ;
39
+ IEnumerable < string > productNames = null ;
39
40
Stream responseStream = null ;
40
41
Exception ex = null ;
41
42
string mimeType = null ;
@@ -76,6 +77,10 @@ public virtual TResponse Request<TResponse>(RequestData requestData)
76
77
//response.Headers.HasKeys() can return false even if response.Headers.AllKeys has values.
77
78
if ( httpWebResponse . SupportsHeaders && httpWebResponse . Headers . Count > 0 && httpWebResponse . Headers . AllKeys . Contains ( "Warning" ) )
78
79
warnings = httpWebResponse . Headers . GetValues ( "Warning" ) ;
80
+
81
+ //response.Headers.HasKeys() can return false even if response.Headers.AllKeys has values.
82
+ if ( httpWebResponse . SupportsHeaders && httpWebResponse . Headers . Count > 0 && httpWebResponse . Headers . AllKeys . Contains ( "X-elastic-product" ) )
83
+ productNames = httpWebResponse . Headers . GetValues ( "X-elastic-product" ) ;
79
84
}
80
85
catch ( WebException e )
81
86
{
@@ -85,7 +90,7 @@ public virtual TResponse Request<TResponse>(RequestData requestData)
85
90
}
86
91
87
92
responseStream ??= Stream . Null ;
88
- var response = ResponseBuilder . ToResponse < TResponse > ( requestData , ex , statusCode , warnings , responseStream , mimeType ) ;
93
+ var response = ResponseBuilder . ToResponse < TResponse > ( requestData , ex , statusCode , warnings , responseStream , mimeType , productNames . FirstOrDefault ( ) ) ;
89
94
90
95
// set TCP and threadpool stats on the response here so that in the event the request fails after the point of
91
96
// gathering stats, they are still exposed on the call details. Ideally these would be set inside ResponseBuilder.ToResponse,
@@ -103,6 +108,7 @@ CancellationToken cancellationToken
103
108
Action unregisterWaitHandle = null ;
104
109
int ? statusCode = null ;
105
110
IEnumerable < string > warnings = null ;
111
+ IEnumerable < string > productNames = null ;
106
112
Stream responseStream = null ;
107
113
Exception ex = null ;
108
114
string mimeType = null ;
@@ -151,6 +157,10 @@ CancellationToken cancellationToken
151
157
HandleResponse ( httpWebResponse , out statusCode , out responseStream , out mimeType ) ;
152
158
if ( httpWebResponse . SupportsHeaders && httpWebResponse . Headers . HasKeys ( ) && httpWebResponse . Headers . AllKeys . Contains ( "Warning" ) )
153
159
warnings = httpWebResponse . Headers . GetValues ( "Warning" ) ;
160
+
161
+ //response.Headers.HasKeys() can return false even if response.Headers.AllKeys has values.
162
+ if ( httpWebResponse . SupportsHeaders && httpWebResponse . Headers . Count > 0 && httpWebResponse . Headers . AllKeys . Contains ( "X-elastic-product" ) )
163
+ productNames = httpWebResponse . Headers . GetValues ( "X-elastic-product" ) ;
154
164
}
155
165
}
156
166
catch ( WebException e )
@@ -165,10 +175,10 @@ CancellationToken cancellationToken
165
175
}
166
176
responseStream ??= Stream . Null ;
167
177
var response = await ResponseBuilder . ToResponseAsync < TResponse >
168
- ( requestData , ex , statusCode , warnings , responseStream , mimeType , cancellationToken )
178
+ ( requestData , ex , statusCode , warnings , responseStream , mimeType , productNames . FirstOrDefault ( ) , cancellationToken )
169
179
. ConfigureAwait ( false ) ;
170
180
171
- // set TCP and threadpool stats on the response here so that in the event the request fails after the point of
181
+ // set TCP and thread pool stats on the response here so that in the event the request fails after the point of
172
182
// gathering stats, they are still exposed on the call details. Ideally these would be set inside ResponseBuilder.ToResponse,
173
183
// but doing so would be a breaking change in 7.x
174
184
response . ApiCall . TcpStats = tcpStats ;
0 commit comments