@@ -266,7 +266,8 @@ public async Task HttpTrigger_Post_Dynamic()
266266 Method = HttpMethod . Post ,
267267 Content = new StringContent ( input . ToString ( ) )
268268 } ;
269- request . SetConfiguration ( new HttpConfiguration ( ) ) ;
269+ request . SetConfiguration ( Fixture . RequestConfiguration ) ;
270+ request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "text/plain" ) ) ;
270271 request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/json" ) ;
271272
272273 Dictionary < string , object > arguments = new Dictionary < string , object >
@@ -283,6 +284,44 @@ public async Task HttpTrigger_Post_Dynamic()
283284 Assert . Equal ( "Name: Mathew Charles, Location: Seattle" , body ) ;
284285 }
285286
287+ [ Theory ]
288+ [ InlineData ( "application/json" , "\" Name: Fabio Cavalcante, Location: Seattle\" " ) ]
289+ [ InlineData ( "application/xml" , "<string xmlns=\" http://schemas.microsoft.com/2003/10/Serialization/\" >Name: Fabio Cavalcante, Location: Seattle</string>" ) ]
290+ [ InlineData ( "text/plain" , "Name: Fabio Cavalcante, Location: Seattle" ) ]
291+ public async Task HttpTrigger_GetWithAccept_NegotiatesContent ( string accept , string expectedBody )
292+ {
293+ var input = new JObject
294+ {
295+ { "name" , "Fabio Cavalcante" } ,
296+ { "location" , "Seattle" }
297+ } ;
298+
299+ HttpRequestMessage request = new HttpRequestMessage
300+ {
301+ RequestUri = new Uri ( string . Format ( "http://localhost/api/httptrigger-dynamic" ) ) ,
302+ Method = HttpMethod . Post ,
303+ Content = new StringContent ( input . ToString ( ) )
304+ } ;
305+ request . SetConfiguration ( Fixture . RequestConfiguration ) ;
306+ request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( accept ) ) ;
307+ request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/json" ) ;
308+
309+ Dictionary < string , object > arguments = new Dictionary < string , object >
310+ {
311+ { "input" , request } ,
312+ { ScriptConstants . SystemTriggerParameterName , request }
313+ } ;
314+
315+ await Fixture . Host . CallAsync ( "HttpTrigger-Dynamic" , arguments ) ;
316+
317+ HttpResponseMessage response = ( HttpResponseMessage ) request . Properties [ ScriptConstants . AzureFunctionsHttpResponseKey ] ;
318+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
319+ Assert . Equal ( accept , response . Content . Headers . ContentType . MediaType ) ;
320+
321+ string body = await response . Content . ReadAsStringAsync ( ) ;
322+ Assert . Equal ( expectedBody , body ) ;
323+ }
324+
286325 public class TestFixture : EndToEndTestFixture
287326 {
288327 private const string ScriptRoot = @"TestScripts\CSharp" ;
0 commit comments