File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,18 @@ impl Response {
40
40
self . 0 . headers ( )
41
41
}
42
42
43
+ /// Gets the Deprecation warning response headers
44
+ ///
45
+ /// Deprecation headers signal the use of Elasticsearch functionality
46
+ /// or features that are deprecated and will be removed in a future release.
47
+ pub fn warning_headers ( & self ) -> impl Iterator < Item = & str > {
48
+ self . 0
49
+ . headers ( )
50
+ . get_all ( "Warning" )
51
+ . iter ( )
52
+ . map ( |w| w. to_str ( ) . unwrap ( ) )
53
+ }
54
+
43
55
/// Asynchronously reads the response body as JSON
44
56
///
45
57
/// Reading the response body consumes `self`
Original file line number Diff line number Diff line change @@ -87,6 +87,49 @@ async fn x_opaque_id_header() -> Result<(), failure::Error> {
87
87
Ok ( ( ) )
88
88
}
89
89
90
+ #[ tokio:: test]
91
+ async fn deprecation_warning_headers ( ) -> Result < ( ) , failure:: Error > {
92
+ let client = client:: create_default ( ) ;
93
+ let _ = index_documents ( & client) . await ?;
94
+ let response = client
95
+ . search ( SearchParts :: None )
96
+ . body ( json ! {
97
+ {
98
+ "aggs" : {
99
+ "titles" : {
100
+ "terms" : {
101
+ "field" : "title.keyword" ,
102
+ "order" : [ {
103
+ "_term" : "asc"
104
+ } ]
105
+ }
106
+ }
107
+ } ,
108
+ "query" : {
109
+ "function_score" : {
110
+ "functions" : [ {
111
+ "random_score" : {
112
+ "seed" : 1337
113
+ }
114
+ } ] ,
115
+ "query" : {
116
+ "match_all" : { }
117
+ }
118
+ }
119
+ } ,
120
+ "size" : 0
121
+ }
122
+ } )
123
+ . send ( )
124
+ . await ?;
125
+
126
+ let warnings = response. warning_headers ( ) . collect :: < Vec < & str > > ( ) ;
127
+ assert ! ( warnings. len( ) > 0 ) ;
128
+ assert ! ( warnings. iter( ) . any( |& w| w. contains( "Deprecated aggregation order key" ) ) ) ;
129
+
130
+ Ok ( ( ) )
131
+ }
132
+
90
133
#[ tokio:: test]
91
134
async fn serialize_querystring ( ) -> Result < ( ) , failure:: Error > {
92
135
let server = server:: http ( move |req| async move {
You can’t perform that action at this time.
0 commit comments