Skip to content

Commit e1bdd6e

Browse files
committed
Do not send any content if root is pinged by scale controller
1 parent 7728897 commit e1bdd6e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public override async Task<HttpResponseMessage> ExecuteAsync(HttpControllerConte
5252
{
5353
// if the request is to the root and we can't find any matching FunctionDescriptors which might have been setup by proxies
5454
// then homepage logic will be applied.
55-
return IsHomepageDisabled
55+
return (IsHomepageDisabled || request.IsAntaresInternalRequest())
5656
? new HttpResponseMessage(HttpStatusCode.NoContent)
5757
: new HttpResponseMessage(HttpStatusCode.OK)
5858
{

test/WebJobs.Script.Tests.Integration/SamplesEndToEndTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ public async Task Home_Get_WithHomepageDisabled_Succeeds()
210210
}
211211
}
212212

213+
[Fact]
214+
public async Task Home_Get_InAzureEnvironment_AsInternalRequest_ReturnsNoContent()
215+
{
216+
// Pings to the site root should not return the homepage content if they are internal requests.
217+
// This test sets a website instance Id which means that we'll go down the IsAzureEnvironment = true codepath
218+
// but the sent request does NOT include an X-ARR-LOG-ID header. This indicates the request was internal.
219+
220+
using (new TestScopedSettings(_settingsManager, EnvironmentSettingNames.AzureWebsiteInstanceId, "123"))
221+
{
222+
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, string.Empty);
223+
224+
HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request);
225+
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
226+
}
227+
}
228+
213229
[Fact]
214230
public async Task HttpTrigger_CSharp_Poco_Post_Succeeds()
215231
{

0 commit comments

Comments
 (0)