@@ -116,7 +116,7 @@ protected override async Task InvokeCore(object[] parameters, FunctionInvocation
116116 DataType dataType = _trigger . DataType ?? DataType . String ;
117117
118118 var userTraceWriter = CreateUserTraceWriter ( context . TraceWriter ) ;
119- var scriptExecutionContext = CreateScriptExecutionContext ( input , dataType , userTraceWriter , context ) ;
119+ var scriptExecutionContext = await CreateScriptExecutionContextAsync ( input , dataType , userTraceWriter , context ) . ConfigureAwait ( false ) ;
120120 var bindingData = ( Dictionary < string , object > ) scriptExecutionContext [ "bindingData" ] ;
121121
122122 await ProcessInputBindingsAsync ( context . Binder , scriptExecutionContext , bindingData ) ;
@@ -253,7 +253,7 @@ protected override void OnScriptFileChanged(object sender, FileSystemEventArgs e
253253 }
254254 }
255255
256- private Dictionary < string , object > CreateScriptExecutionContext ( object input , DataType dataType , TraceWriter traceWriter , FunctionInvocationContext invocationContext )
256+ private async Task < Dictionary < string , object > > CreateScriptExecutionContextAsync ( object input , DataType dataType , TraceWriter traceWriter , FunctionInvocationContext invocationContext )
257257 {
258258 // create a TraceWriter wrapper that can be exposed to Node.js
259259 var log = ( Func < object , Task < object > > ) ( p =>
@@ -303,12 +303,11 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Da
303303 context [ "_entryPoint" ] = _entryPoint ;
304304 }
305305
306- if ( input is HttpRequestMessage )
306+ // convert the request to a json object
307+ if ( input is HttpRequestMessage request )
307308 {
308- // convert the request to a json object
309- HttpRequestMessage request = ( HttpRequestMessage ) input ;
310- string rawBody = null ;
311- var requestObject = CreateRequestObject ( request , out rawBody ) ;
309+ ( Dictionary < string , object > requestObject , string rawBody ) = await CreateRequestObjectAsync ( request ) . ConfigureAwait ( false ) ;
310+
312311 input = requestObject ;
313312
314313 if ( rawBody != null )
@@ -458,9 +457,9 @@ internal static bool IsEdgeSupportedType(Type type)
458457 return false ;
459458 }
460459
461- private static Dictionary < string , object > CreateRequestObject ( HttpRequestMessage request , out string rawBody )
460+ private static async Task < ( Dictionary < string , object > request , string rawBody ) > CreateRequestObjectAsync ( HttpRequestMessage request )
462461 {
463- rawBody = null ;
462+ string rawBody = null ;
464463
465464 // TODO: need to provide access to remaining request properties
466465 Dictionary < string , object > requestObject = new Dictionary < string , object > ( ) ;
@@ -483,7 +482,7 @@ private static Dictionary<string, object> CreateRequestObject(HttpRequestMessage
483482 {
484483 if ( contentType . MediaType == "application/json" )
485484 {
486- body = request . Content . ReadAsStringAsync ( ) . Result ;
485+ body = await request . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
487486 if ( TryConvertJson ( ( string ) body , out jsonObject ) )
488487 {
489488 // if the content - type of the request is json, deserialize into an object or array
@@ -493,14 +492,14 @@ private static Dictionary<string, object> CreateRequestObject(HttpRequestMessage
493492 }
494493 else if ( contentType . MediaType == "application/octet-stream" )
495494 {
496- body = request . Content . ReadAsByteArrayAsync ( ) . Result ;
495+ body = await request . Content . ReadAsByteArrayAsync ( ) . ConfigureAwait ( false ) ;
497496 }
498497 }
499498
500499 if ( body == null )
501500 {
502501 // if we don't have a content type, default to reading as string
503- body = rawBody = request . Content . ReadAsStringAsync ( ) . Result ;
502+ body = rawBody = await request . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
504503 }
505504
506505 requestObject [ "body" ] = body ;
@@ -514,7 +513,7 @@ private static Dictionary<string, object> CreateRequestObject(HttpRequestMessage
514513 requestObject [ "params" ] = routeData ;
515514 }
516515
517- return requestObject ;
516+ return ( requestObject , rawBody ) ;
518517 }
519518
520519 /// <summary>
0 commit comments