@@ -11,8 +11,8 @@ namespace Simplify.Web.Modules
1111 /// </summary>
1212 public class WebContext : IWebContext
1313 {
14- private readonly SemaphoreSlim _formReadLock = new SemaphoreSlim ( 1 , 1 ) ;
15- private readonly SemaphoreSlim _requestBodyReadLock = new SemaphoreSlim ( 1 , 1 ) ;
14+ private readonly SemaphoreSlim _formReadSemaphore = new SemaphoreSlim ( 1 , 1 ) ;
15+ private readonly SemaphoreSlim _requestBodyReadSemaphore = new SemaphoreSlim ( 1 , 1 ) ;
1616
1717 private IFormCollection ? _form ;
1818 private string ? _requestBody ;
@@ -134,18 +134,18 @@ public string RequestBody
134134 /// </summary>
135135 public async Task ReadFormAsync ( )
136136 {
137- await _formReadLock . WaitAsync ( ) ;
138-
139137 if ( _form != null )
140138 return ;
141139
140+ await _formReadSemaphore . WaitAsync ( ) ;
141+
142142 try
143143 {
144144 _form = await Context . Request . ReadFormAsync ( ) ;
145145 }
146146 finally
147147 {
148- _formReadLock . Release ( ) ;
148+ _formReadSemaphore . Release ( ) ;
149149 }
150150 }
151151
@@ -154,11 +154,11 @@ public async Task ReadFormAsync()
154154 /// </summary>
155155 public async Task ReadRequestBodyAsync ( )
156156 {
157- await _requestBodyReadLock . WaitAsync ( ) ;
158-
159157 if ( _requestBody != null )
160158 return ;
161159
160+ await _requestBodyReadSemaphore . WaitAsync ( ) ;
161+
162162 try
163163 {
164164 using var reader = new StreamReader ( Context . Request . Body ) ;
@@ -167,7 +167,7 @@ public async Task ReadRequestBodyAsync()
167167 }
168168 finally
169169 {
170- _requestBodyReadLock . Release ( ) ;
170+ _requestBodyReadSemaphore . Release ( ) ;
171171 }
172172 }
173173 }
0 commit comments