Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1e7be3d

Browse files
committed
Merge fixes/detect-enterprise-host into release/1.0.16.1
2 parents d590181 + 283bce3 commit 1e7be3d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/GitHub.Api/SimpleApiClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ async Task<Repository> GetRepositoryInternal()
7171
}
7272
}
7373
// it'll throw if it's private or an enterprise instance requiring authentication
74-
catch (ApiException)
74+
catch (ApiException apiex)
7575
{
7676
if (!HostAddress.IsGitHubDotComUri(OriginalUrl.ToRepositoryUrl()))
77-
isEnterprise = true;
77+
isEnterprise = apiex.HttpResponse?.Headers.ContainsKey("X-GitHub-Request-Id");
7878
}
7979
catch {}
8080
finally

src/GitHub.Exports/Services/EnterpriseProbeTask.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ public async Task<EnterpriseProbeResult> ProbeAsync(Uri enterpriseBaseUrl)
3737
};
3838
request.Headers.Add("User-Agent", productHeader.ToString());
3939

40+
var success = false;
4041
var ret = await httpClient
4142
.Send(request, CancellationToken.None)
42-
.Catch(ex => null);
43+
.Catch(ex => {
44+
var apiex = ex as ApiException;
45+
if (apiex != null)
46+
success = apiex.HttpResponse?.Headers.ContainsKey("X-GitHub-Request-Id") ?? false;
47+
return null;
48+
});
4349

4450
if (ret == null)
45-
return EnterpriseProbeResult.Failed;
51+
return success ? EnterpriseProbeResult.Ok : EnterpriseProbeResult.Failed;
4652
else if (ret.StatusCode == HttpStatusCode.OK)
4753
return EnterpriseProbeResult.Ok;
4854
return EnterpriseProbeResult.NotFound;

0 commit comments

Comments
 (0)