@@ -43,7 +43,7 @@ internal SessionEventArgs(ProxyServer server, ProxyEndPoint endPoint,
43
43
}
44
44
45
45
protected SessionEventArgs ( ProxyServer server , ProxyEndPoint endPoint ,
46
- Request request , CancellationTokenSource cancellationTokenSource )
46
+ Request ? request , CancellationTokenSource cancellationTokenSource )
47
47
: base ( server , endPoint , cancellationTokenSource , request )
48
48
{
49
49
}
@@ -70,7 +70,7 @@ public bool ReRequest
70
70
/// <summary>
71
71
/// Occurs when multipart request part sent.
72
72
/// </summary>
73
- public event EventHandler < MultipartRequestPartSentEventArgs > MultipartRequestPartSent ;
73
+ public event EventHandler < MultipartRequestPartSentEventArgs > ? MultipartRequestPartSent ;
74
74
75
75
private ICustomStreamReader getStreamReader ( bool isRequest )
76
76
{
@@ -105,7 +105,7 @@ private async Task readRequestBodyAsync(CancellationToken cancellationToken)
105
105
request . ReadHttp2BodyTaskCompletionSource = tcs ;
106
106
107
107
// signal to HTTP/2 copy frame method to continue
108
- request . ReadHttp2BeforeHandlerTaskCompletionSource . SetResult ( true ) ;
108
+ request . ReadHttp2BeforeHandlerTaskCompletionSource ! . SetResult ( true ) ;
109
109
110
110
await tcs . Task ;
111
111
@@ -135,11 +135,11 @@ internal async Task ClearResponse(CancellationToken cancellationToken)
135
135
HttpClient . Response = new Response ( ) ;
136
136
}
137
137
138
- internal void OnMultipartRequestPartSent ( string boundary , HeaderCollection headers )
138
+ internal void OnMultipartRequestPartSent ( ReadOnlySpan < char > boundary , HeaderCollection headers )
139
139
{
140
140
try
141
141
{
142
- MultipartRequestPartSent ? . Invoke ( this , new MultipartRequestPartSentEventArgs ( boundary , headers ) ) ;
142
+ MultipartRequestPartSent ? . Invoke ( this , new MultipartRequestPartSentEventArgs ( boundary . ToString ( ) , headers ) ) ;
143
143
}
144
144
catch ( Exception ex )
145
145
{
@@ -177,7 +177,7 @@ private async Task readResponseBodyAsync(CancellationToken cancellationToken)
177
177
response . ReadHttp2BodyTaskCompletionSource = tcs ;
178
178
179
179
// signal to HTTP/2 copy frame method to continue
180
- response . ReadHttp2BeforeHandlerTaskCompletionSource . SetResult ( true ) ;
180
+ response . ReadHttp2BeforeHandlerTaskCompletionSource ! . SetResult ( true ) ;
181
181
182
182
await tcs . Task ;
183
183
@@ -252,7 +252,7 @@ internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode t
252
252
if ( contentLength > 0 && hasMulipartEventSubscribers && request . IsMultipartFormData )
253
253
{
254
254
var reader = getStreamReader ( true ) ;
255
- string boundary = HttpHelper . GetBoundaryFromContentType ( request . ContentType ) ;
255
+ var boundary = HttpHelper . GetBoundaryFromContentType ( request . ContentType ) ;
256
256
257
257
using ( var copyStream = new CopyStream ( reader , writer , BufferPool ) )
258
258
{
@@ -268,7 +268,7 @@ internal async Task CopyRequestBodyAsync(HttpWriter writer, TransformationMode t
268
268
{
269
269
var headers = new HeaderCollection ( ) ;
270
270
await HeaderParser . ReadHeaders ( copyStream , headers , cancellationToken ) ;
271
- OnMultipartRequestPartSent ( boundary , headers ) ;
271
+ OnMultipartRequestPartSent ( boundary . Span , headers ) ;
272
272
}
273
273
}
274
274
@@ -286,7 +286,7 @@ internal async Task CopyResponseBodyAsync(HttpWriter writer, TransformationMode
286
286
await copyBodyAsync ( false , false , writer , transformation , OnDataReceived , cancellationToken ) ;
287
287
}
288
288
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 )
290
290
{
291
291
var stream = getStreamReader ( isRequest ) ;
292
292
@@ -302,9 +302,9 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
302
302
}
303
303
304
304
LimitedStream limitedStream ;
305
- Stream decompressStream = null ;
305
+ Stream ? decompressStream = null ;
306
306
307
- string contentEncoding = useOriginalHeaderValues ? requestResponse . OriginalContentEncoding : requestResponse . ContentEncoding ;
307
+ string ? contentEncoding = useOriginalHeaderValues ? requestResponse . OriginalContentEncoding : requestResponse . ContentEncoding ;
308
308
309
309
Stream s = limitedStream = new LimitedStream ( stream , BufferPool , isChunked , contentLength ) ;
310
310
@@ -333,7 +333,7 @@ private async Task copyBodyAsync(bool isRequest, bool useOriginalHeaderValues, H
333
333
/// Read a line from the byte stream
334
334
/// </summary>
335
335
/// <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 )
337
337
{
338
338
int bufferDataLength = 0 ;
339
339
@@ -360,7 +360,7 @@ private async Task<long> readUntilBoundaryAsync(ICustomStreamReader reader, long
360
360
bool ok = true ;
361
361
for ( int i = 0 ; i < boundary . Length ; i ++ )
362
362
{
363
- if ( buffer [ startIdx + i ] != boundary [ i ] )
363
+ if ( buffer [ startIdx + i ] != boundary . Span [ i ] )
364
364
{
365
365
ok = false ;
366
366
break ;
@@ -519,7 +519,7 @@ public void SetResponseBodyString(string body)
519
519
/// <param name="html">HTML content to sent.</param>
520
520
/// <param name="headers">HTTP response headers.</param>
521
521
/// <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 ,
523
523
bool closeServerConnection = false )
524
524
{
525
525
var response = new OkResponse ( ) ;
@@ -541,7 +541,7 @@ public void Ok(string html, Dictionary<string, HttpHeader> headers = null,
541
541
/// <param name="result">The html content bytes.</param>
542
542
/// <param name="headers">The HTTP headers.</param>
543
543
/// <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 ,
545
545
bool closeServerConnection = false )
546
546
{
547
547
var response = new OkResponse ( ) ;
@@ -562,7 +562,7 @@ public void Ok(byte[] result, Dictionary<string, HttpHeader> headers = null,
562
562
/// <param name="headers">The HTTP headers.</param>
563
563
/// <param name="closeServerConnection">Close the server connection used by request if any?</param>
564
564
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 )
566
566
{
567
567
var response = new GenericResponse ( status ) ;
568
568
response . HttpVersion = HttpClient . Request . HttpVersion ;
0 commit comments