Skip to content

Commit 60b87b1

Browse files
committed
minimize diffs
1 parent 83013be commit 60b87b1

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

dotnet/src/webdriver/DriverService.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,23 @@ protected async virtual Task<bool> IsInitializedAsync()
189189
{
190190
try
191191
{
192-
using var httpClient = new HttpClient();
193-
httpClient.DefaultRequestHeaders.ConnectionClose = true;
194-
httpClient.Timeout = TimeSpan.FromSeconds(5);
195-
196-
Uri serviceHealthUri = new Uri(this.ServiceUrl, new Uri(DriverCommand.Status, UriKind.Relative));
197-
using var response = await httpClient.GetAsync(serviceHealthUri);
192+
using (var httpClient = new HttpClient())
193+
{
194+
httpClient.DefaultRequestHeaders.ConnectionClose = true;
195+
httpClient.Timeout = TimeSpan.FromSeconds(5);
198196

199-
// Checking the response from the 'status' end point. Note that we are simply checking
200-
// that the HTTP status returned is a 200 status, and that the response has the correct
201-
// Content-Type header. A more sophisticated check would parse the JSON response and
202-
// validate its values. At the moment we do not do this more sophisticated check.
203-
bool isInitialized = response.StatusCode == HttpStatusCode.OK && response.Content.Headers.ContentType is { MediaType: string mediaType } && mediaType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase);
197+
Uri serviceHealthUri = new Uri(this.ServiceUrl, new Uri(DriverCommand.Status, UriKind.Relative));
198+
using (var response = await httpClient.GetAsync(serviceHealthUri))
199+
{
200+
// Checking the response from the 'status' end point. Note that we are simply checking
201+
// that the HTTP status returned is a 200 status, and that the response has the correct
202+
// Content-Type header. A more sophisticated check would parse the JSON response and
203+
// validate its values. At the moment we do not do this more sophisticated check.
204+
bool isInitialized = response.StatusCode == HttpStatusCode.OK && response.Content.Headers.ContentType is { MediaType: string mediaType } && mediaType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase);
204205

205-
return isInitialized;
206+
return isInitialized;
207+
}
208+
}
206209
}
207210
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
208211
{

0 commit comments

Comments
 (0)