Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f7ad277

Browse files
committed
Use null propagation
1 parent e191cb9 commit f7ad277

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/ServiceStack.Text/HttpUtils.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,7 @@ public static string SendStringToUrl(this string url, string method = null,
502502
webReq.Accept = accept;
503503
PclExport.Instance.AddCompression(webReq);
504504

505-
if (requestFilter != null)
506-
{
507-
requestFilter(webReq);
508-
}
505+
requestFilter?.Invoke(webReq);
509506

510507
if (ResultsFilter != null)
511508
{
@@ -525,10 +522,8 @@ public static string SendStringToUrl(this string url, string method = null,
525522
using (var stream = webRes.GetResponseStream())
526523
using (var reader = new StreamReader(stream))
527524
{
528-
if (responseFilter != null)
529-
{
530-
responseFilter((HttpWebResponse)webRes);
531-
}
525+
responseFilter?.Invoke((HttpWebResponse)webRes);
526+
532527
return reader.ReadToEnd();
533528
}
534529
}
@@ -546,10 +541,7 @@ public static Task<string> SendStringToUrlAsync(this string url, string method =
546541
webReq.Accept = accept;
547542
PclExport.Instance.AddCompression(webReq);
548543

549-
if (requestFilter != null)
550-
{
551-
requestFilter(webReq);
552-
}
544+
requestFilter?.Invoke(webReq);
553545

554546
if (ResultsFilter != null)
555547
{
@@ -585,10 +577,7 @@ public static Task<string> SendStringToUrlAsync(this string url, string method =
585577
}
586578

587579
var webRes = task.Result;
588-
if (responseFilter != null)
589-
{
590-
responseFilter((HttpWebResponse)webRes);
591-
}
580+
responseFilter?.Invoke((HttpWebResponse)webRes);
592581

593582
using (var stream = webRes.GetResponseStream())
594583
using (var reader = new StreamReader(stream))

0 commit comments

Comments
 (0)