Skip to content

Commit 89b896c

Browse files
committed
Support GET for ping endpoint
1 parent 228e0f1 commit 89b896c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,16 @@ public IHttpActionResult GetHostStatus()
133133
}
134134
}
135135

136+
[HttpGet]
136137
[HttpPost]
137138
[Route("admin/host/ping")]
138139
[AllowAnonymous]
139-
public IHttpActionResult Ping()
140+
public HttpResponseMessage Ping()
140141
{
141-
return Ok();
142+
var response = new HttpResponseMessage(HttpStatusCode.OK);
143+
response.Headers.Add("Cache-Control", "no-store, no-cache");
144+
145+
return response;
142146
}
143147

144148
[HttpPost]

src/WebJobs.Script.WebHost/GlobalSuppressions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,5 @@
113113
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Azure.WebJobs.Script.WebHost.WebHostResolver.#CreateDefaultTraceWriter(Microsoft.Azure.WebJobs.Script.WebHost.WebHostSettings)")]
114114
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Azure.WebJobs.Script.WebHost.WebHostResolver.#CreateDefaultLoggerFactory(Microsoft.Azure.WebJobs.Script.WebHost.WebHostSettings)")]
115115
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.FunctionsSystemLogsEventSource.#SetActivityId(System.String)")]
116+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Azure.WebJobs.Script.WebHost.Controllers.AdminController.#Ping()")]
116117

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,13 +994,17 @@ public async Task ServiceBusTopicTrigger_ManualInvoke_Succeeds()
994994
Assert.Equal(value, result.Trim());
995995
}
996996

997-
[Fact]
998-
public async Task HostPing_Succeeds()
997+
[Theory]
998+
[InlineData("GET")]
999+
[InlineData("POST")]
1000+
public async Task HostPing_Succeeds(string method)
9991001
{
10001002
string uri = "admin/host/ping";
1001-
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);
1002-
HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request);
1003+
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(method), uri);
1004+
HttpResponseMessage response = await _fixture.HttpClient.SendAsync(request);
10031005
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
1006+
var cacheHeader = response.Headers.GetValues("Cache-Control").Single();
1007+
Assert.Equal("no-store, no-cache", cacheHeader);
10041008
}
10051009

10061010
[Fact]

0 commit comments

Comments
 (0)