@@ -160,6 +160,43 @@ public void HttpObjects_Query(string queryString, string[] expectedKeys, string[
160
160
}
161
161
}
162
162
163
+ [ Theory ]
164
+ [ InlineData ( true , new string [ ] { "hello" , "x-mx-key" } , new string [ ] { "world" , "value" } , new string [ ] { "hello" , "x-mx-key" } , new string [ ] { "world" , "value" } ) ]
165
+ [ InlineData ( true , new string [ ] { "hello" , "empty" , "x-mx-key" } , new string [ ] { "world" , "" , "value" } , new string [ ] { "hello" , "x-mx-key" } , new string [ ] { "world" , "value" } ) ] // Removes empty value query params
166
+ [ InlineData ( false , new string [ ] { "hello" , "x-mx-key" } , new string [ ] { "world" , "value" } , new string [ ] { "hello" , "x-mx-key" } , new string [ ] { "world" , "value" } ) ]
167
+ [ InlineData ( false , new string [ ] { "hello" , "empty" , "x-mx-key" } , new string [ ] { "world" , "" , "value" } , new string [ ] { "hello" , "empty" , "x-mx-key" } , new string [ ] { "world" , "" , "value" } ) ]
168
+
169
+ public void HttpObjects_Headers ( bool ignoreEmptyValues , string [ ] headerKeys , string [ ] headerValues , string [ ] expectedKeys , string [ ] expectedValues )
170
+ {
171
+ var logger = MockNullLoggerFactory . CreateLogger ( ) ;
172
+ // Capability must be enabled
173
+ var capabilities = new Capabilities ( logger ) ;
174
+
175
+ if ( ignoreEmptyValues )
176
+ {
177
+ capabilities . UpdateCapabilities ( new MapField < string , string >
178
+ {
179
+ { RpcWorkerConstants . IgnoreEmptyValuedRpcHttpHeaders , "true" }
180
+ } ) ;
181
+ }
182
+
183
+ var headerDictionary = new HeaderDictionary ( ) ;
184
+ for ( int i = 0 ; i < headerValues . Length ; i ++ )
185
+ {
186
+ headerDictionary . Add ( headerKeys [ i ] , headerValues [ i ] ) ;
187
+ }
188
+
189
+ HttpRequest request = HttpTestHelpers . CreateHttpRequest ( "GET" , $ "http://localhost/api/httptrigger-scenarios", headerDictionary ) ;
190
+
191
+ var rpcRequestObject = request . ToRpc ( logger , capabilities ) ;
192
+ // Same key and value strings for each pair
193
+ for ( int i = 0 ; i < expectedKeys . Length ; i ++ )
194
+ {
195
+ Assert . True ( rpcRequestObject . Http . Headers . ContainsKey ( expectedKeys [ i ] ) ) ;
196
+ Assert . Equal ( expectedValues [ i ] , rpcRequestObject . Http . Headers . GetValueOrDefault ( expectedKeys [ i ] ) ) ;
197
+ }
198
+ }
199
+
163
200
[ Theory ]
164
201
[ InlineData ( BindingDirection . In , "blob" , DataType . String ) ]
165
202
[ InlineData ( BindingDirection . Out , "blob" , DataType . Binary ) ]
0 commit comments