@@ -116,7 +116,7 @@ protected override async Task InvokeCore(object[] parameters, FunctionInvocation
116
116
DataType dataType = _trigger . DataType ?? DataType . String ;
117
117
118
118
var userTraceWriter = CreateUserTraceWriter ( context . TraceWriter ) ;
119
- var scriptExecutionContext = CreateScriptExecutionContext ( input , dataType , userTraceWriter , context ) ;
119
+ var scriptExecutionContext = await CreateScriptExecutionContextAsync ( input , dataType , userTraceWriter , context ) . ConfigureAwait ( false ) ;
120
120
var bindingData = ( Dictionary < string , object > ) scriptExecutionContext [ "bindingData" ] ;
121
121
122
122
await ProcessInputBindingsAsync ( context . Binder , scriptExecutionContext , bindingData ) ;
@@ -253,7 +253,7 @@ protected override void OnScriptFileChanged(object sender, FileSystemEventArgs e
253
253
}
254
254
}
255
255
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 )
257
257
{
258
258
// create a TraceWriter wrapper that can be exposed to Node.js
259
259
var log = ( Func < object , Task < object > > ) ( p =>
@@ -303,12 +303,11 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Da
303
303
context [ "_entryPoint" ] = _entryPoint ;
304
304
}
305
305
306
- if ( input is HttpRequestMessage )
306
+ // convert the request to a json object
307
+ if ( input is HttpRequestMessage request )
307
308
{
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
+
312
311
input = requestObject ;
313
312
314
313
if ( rawBody != null )
@@ -458,9 +457,9 @@ internal static bool IsEdgeSupportedType(Type type)
458
457
return false ;
459
458
}
460
459
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 )
462
461
{
463
- rawBody = null ;
462
+ string rawBody = null ;
464
463
465
464
// TODO: need to provide access to remaining request properties
466
465
Dictionary < string , object > requestObject = new Dictionary < string , object > ( ) ;
@@ -483,7 +482,7 @@ private static Dictionary<string, object> CreateRequestObject(HttpRequestMessage
483
482
{
484
483
if ( contentType . MediaType == "application/json" )
485
484
{
486
- body = request . Content . ReadAsStringAsync ( ) . Result ;
485
+ body = await request . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
487
486
if ( TryConvertJson ( ( string ) body , out jsonObject ) )
488
487
{
489
488
// 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
493
492
}
494
493
else if ( contentType . MediaType == "application/octet-stream" )
495
494
{
496
- body = request . Content . ReadAsByteArrayAsync ( ) . Result ;
495
+ body = await request . Content . ReadAsByteArrayAsync ( ) . ConfigureAwait ( false ) ;
497
496
}
498
497
}
499
498
500
499
if ( body == null )
501
500
{
502
501
// 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 ) ;
504
503
}
505
504
506
505
requestObject [ "body" ] = body ;
@@ -514,7 +513,7 @@ private static Dictionary<string, object> CreateRequestObject(HttpRequestMessage
514
513
requestObject [ "params" ] = routeData ;
515
514
}
516
515
517
- return requestObject ;
516
+ return ( requestObject , rawBody ) ;
518
517
}
519
518
520
519
/// <summary>
0 commit comments