You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add leaveOpen=true to ReadBodyFromRequestAsync, so the ctx.Request.Body is not disposed
* add helper test function getReqBody, and use the leaveOpen = true at the getBody
* add more tests to assert that the body is being disposed correctly when using ReadBodyFromRequestAsync, and add a new ReadBodyFromRequestAsync function that let's the user define the value of the leaveOpen parameter (useful for tests)
use reader =new StreamReader(ctx.Request.Body, Encoding.UTF8)
206
+
use reader =new StreamReader(ctx.Request.Body, Encoding.UTF8, leaveOpen =true)
207
+
return! reader.ReadToEndAsync()
208
+
}
209
+
210
+
/// <summary>
211
+
/// Reads the entire body of the <see cref="Microsoft.AspNetCore.Http.HttpRequest"/> asynchronously and returns it as a <see cref="System.String"/> value. This function let's you decide if you want to leave the ctx.Request.Body element open or not.
212
+
/// </summary>
213
+
/// <param name="ctx">The current http context object.</param>
214
+
/// <param name="leaveOpen">`true` to leave the stream open after the StreamReader object is disposed; otherwise, `false`.</param>
215
+
/// <returns>Returns the contents of the request body as a <see cref="System.Threading.Tasks.Task{System.String}"/>.</returns>
0 commit comments