@@ -43,7 +43,7 @@ internal SessionEventArgs(ProxyServer server, ProxyEndPoint endPoint,
4343 }
4444
4545 protected SessionEventArgs ( ProxyServer server , ProxyEndPoint endPoint ,
46- Request request , CancellationTokenSource cancellationTokenSource )
46+ Request ? request , CancellationTokenSource cancellationTokenSource )
4747 : base ( server , endPoint , cancellationTokenSource , request )
4848 {
4949 }
@@ -70,7 +70,7 @@ public bool ReRequest
7070 /// <summary>
7171 /// Occurs when multipart request part sent.
7272 /// </summary>
73- public event EventHandler < MultipartRequestPartSentEventArgs > MultipartRequestPartSent ;
73+ public event EventHandler < MultipartRequestPartSentEventArgs > ? MultipartRequestPartSent ;
7474
7575 private ICustomStreamReader getStreamReader ( bool isRequest )
7676 {
@@ -105,7 +105,7 @@ private async Task readRequestBodyAsync(CancellationToken cancellationToken)
105105 request . ReadHttp2BodyTaskCompletionSource = tcs ;
106106
107107 // signal to HTTP/2 copy frame method to continue
108- request . ReadHttp2BeforeHandlerTaskCompletionSource . SetResult ( true ) ;
108+ request . ReadHttp2BeforeHandlerTaskCompletionSource ! . SetResult ( true ) ;
109109
110110 await tcs . Task ;
111111
@@ -135,11 +135,11 @@ internal async Task ClearResponse(CancellationToken cancellationToken)
135135 HttpClient . Response = new Response ( ) ;
136136 }
137137
138- internal void OnMultipartRequestPartSent ( string boundary , HeaderCollection headers )
138+ internal void OnMultipartRequestPartSent ( ReadOnlySpan < char > boundary , HeaderCollection headers )
139139 {
140140 try
141141 {
142- MultipartRequestPartSent ? . Invoke ( this , new MultipartRequestPartSentEventArgs ( boundary , headers ) ) ;
142+ MultipartRequestPartSent ? . Invoke ( this , new MultipartRequestPartSentEventArgs ( boundary . ToString ( ) , headers ) ) ;
143143 }
144144 catch ( Exception ex )
145145 {
@@ -177,7 +177,7 @@ private async Task readResponseBodyAsync(CancellationToken cancellationToken)
177177 response . ReadHttp2BodyTaskCompletionSource = tcs ;
178178
179179 // signal to HTTP/2 copy frame method to continue
180- response . ReadHttp2BeforeHandlerTaskCompletionSource . SetResult ( true ) ;
180+ response . ReadHttp2BeforeHandlerTaskCompletionSource ! . SetResult ( true ) ;
181181
182182 await tcs . Task ;
183183
@@ -252,7 +252,7 @@ internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode t
252252 if ( contentLength > 0 && hasMulipartEventSubscribers && request . IsMultipartFormData )
253253 {
254254 var reader = getStreamReader ( true ) ;
255- string boundary = HttpHelper . GetBoundaryFromContentType ( request . ContentType ) ;
255+ var boundary = HttpHelper . GetBoundaryFromContentType ( request . ContentType ) ;
256256
257257 using ( var copyStream = new CopyStream ( reader , writer , BufferPool ) )
258258 {
@@ -268,7 +268,7 @@ internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode t
268268 {
269269 var headers = new HeaderCollection ( ) ;
270270 await HeaderParser . ReadHeaders ( copyStream , headers , cancellationToken ) ;
271- OnMultipartRequestPartSent ( boundary , headers ) ;
271+ OnMultipartRequestPartSent ( boundary . Span , headers ) ;
272272 }
273273 }
274274
@@ -286,7 +286,7 @@ internal async Task CopyResponseBodyAsync(HttpWriter writer, TransformationMode
286286 await copyBodyAsync ( false , false , writer , transformation , OnDataReceived , cancellationToken ) ;
287287 }
288288
289- private async Task copyBodyAsync ( bool isRequest , bool useOriginalHeaderValues , HttpWriter writer , TransformationMode transformation , Action < byte [ ] , int , int > onCopy , CancellationToken cancellationToken )
289+ private async Task copyBodyAsync ( bool isRequest , bool useOriginalHeaderValues , HttpWriter writer , TransformationMode transformation , Action < byte [ ] , int , int > ? onCopy , CancellationToken cancellationToken )
290290 {
291291 var stream = getStreamReader ( isRequest ) ;
292292
@@ -302,9 +302,9 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
302302 }
303303
304304 LimitedStream limitedStream ;
305- Stream decompressStream = null ;
305+ Stream ? decompressStream = null ;
306306
307- string contentEncoding = useOriginalHeaderValues ? requestResponse . OriginalContentEncoding : requestResponse . ContentEncoding ;
307+ string ? contentEncoding = useOriginalHeaderValues ? requestResponse . OriginalContentEncoding : requestResponse . ContentEncoding ;
308308
309309 Stream s = limitedStream = new LimitedStream ( stream , BufferPool , isChunked , contentLength ) ;
310310
@@ -333,7 +333,7 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
333333 /// Read a line from the byte stream
334334 /// </summary>
335335 /// <returns></returns>
336- private async Task < long > readUntilBoundaryAsync ( ICustomStreamReader reader , long totalBytesToRead , string boundary , CancellationToken cancellationToken )
336+ private async Task < long > readUntilBoundaryAsync ( ICustomStreamReader reader , long totalBytesToRead , ReadOnlyMemory < char > boundary , CancellationToken cancellationToken )
337337 {
338338 int bufferDataLength = 0 ;
339339
@@ -360,7 +360,7 @@ private async Task<long> readUntilBoundaryAsync(ICustomStreamReader reader, long
360360 bool ok = true ;
361361 for ( int i = 0 ; i < boundary . Length ; i ++ )
362362 {
363- if ( buffer [ startIdx + i ] != boundary [ i ] )
363+ if ( buffer [ startIdx + i ] != boundary . Span [ i ] )
364364 {
365365 ok = false ;
366366 break ;
@@ -519,7 +519,7 @@ public void SetResponseBodyString(string body)
519519 /// <param name="html">HTML content to sent.</param>
520520 /// <param name="headers">HTTP response headers.</param>
521521 /// <param name="closeServerConnection">Close the server connection used by request if any?</param>
522- public void Ok ( string html , Dictionary < string , HttpHeader > headers = null ,
522+ public void Ok ( string html , Dictionary < string , HttpHeader > ? headers = null ,
523523 bool closeServerConnection = false )
524524 {
525525 var response = new OkResponse ( ) ;
@@ -541,7 +541,7 @@ public void Ok(string html, Dictionary<string, HttpHeader> headers = null,
541541 /// <param name="result">The html content bytes.</param>
542542 /// <param name="headers">The HTTP headers.</param>
543543 /// <param name="closeServerConnection">Close the server connection used by request if any?</param>
544- public void Ok ( byte [ ] result , Dictionary < string , HttpHeader > headers = null ,
544+ public void Ok ( byte [ ] result , Dictionary < string , HttpHeader > ? headers = null ,
545545 bool closeServerConnection = false )
546546 {
547547 var response = new OkResponse ( ) ;
@@ -562,7 +562,7 @@ public void Ok(byte[] result, Dictionary<string, HttpHeader> headers = null,
562562 /// <param name="headers">The HTTP headers.</param>
563563 /// <param name="closeServerConnection">Close the server connection used by request if any?</param>
564564 public void GenericResponse ( string html , HttpStatusCode status ,
565- Dictionary < string , HttpHeader > headers = null , bool closeServerConnection = false )
565+ Dictionary < string , HttpHeader > ? headers = null , bool closeServerConnection = false )
566566 {
567567 var response = new GenericResponse ( status ) ;
568568 response . HttpVersion = HttpClient . Request . HttpVersion ;
0 commit comments