From a2fd925cead2215629ef403ed3390c9465460da4 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 9 Apr 2022 17:36:52 +0530 Subject: [PATCH] WebServiceOtherZonesApi: updated ImportAllowedZones() and ImportBlockedZones() to use async IO for reading request input stream. --- DnsServerCore/WebServiceOtherZonesApi.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DnsServerCore/WebServiceOtherZonesApi.cs b/DnsServerCore/WebServiceOtherZonesApi.cs index b03553dc..42fc336b 100644 --- a/DnsServerCore/WebServiceOtherZonesApi.cs +++ b/DnsServerCore/WebServiceOtherZonesApi.cs @@ -22,6 +22,7 @@ using Newtonsoft.Json; using System.Collections.Generic; using System.IO; using System.Net; +using System.Threading.Tasks; using TechnitiumLibrary.Net.Dns; using TechnitiumLibrary.Net.Dns.ResourceRecords; @@ -199,7 +200,7 @@ namespace DnsServerCore WebServiceZonesApi.WriteRecordsAsJson(new List(records), jsonWriter, false); } - public void ImportAllowedZones(HttpListenerRequest request) + public async Task ImportAllowedZonesAsync(HttpListenerRequest request) { if (!request.ContentType.StartsWith("application/x-www-form-urlencoded")) throw new DnsWebServiceException("Invalid content type. Expected application/x-www-form-urlencoded."); @@ -207,7 +208,7 @@ namespace DnsServerCore string formRequest; using (StreamReader sR = new StreamReader(request.InputStream, request.ContentEncoding)) { - formRequest = sR.ReadToEnd(); + formRequest = await sR.ReadToEndAsync(); } string[] formParts = formRequest.Split('&'); @@ -358,7 +359,7 @@ namespace DnsServerCore WebServiceZonesApi.WriteRecordsAsJson(new List(records), jsonWriter, false); } - public void ImportBlockedZones(HttpListenerRequest request) + public async Task ImportBlockedZonesAsync(HttpListenerRequest request) { if (!request.ContentType.StartsWith("application/x-www-form-urlencoded")) throw new DnsWebServiceException("Invalid content type. Expected application/x-www-form-urlencoded."); @@ -366,7 +367,7 @@ namespace DnsServerCore string formRequest; using (StreamReader sR = new StreamReader(request.InputStream, request.ContentEncoding)) { - formRequest = sR.ReadToEnd(); + formRequest = await sR.ReadToEndAsync(); } string[] formParts = formRequest.Split('&');