Add HEAD support for /_ping endpoint#38570
Merged
thaJeztah merged 1 commit intomoby:masterfrom Jan 31, 2019
Merged
Conversation
Member
Author
|
@cpuguy83 and last ping in this series 👍 😂 |
Member
Author
Member
Author
|
/cc @vsaraswat Also may needs an update to the changes made in docker/docs#4758 if this is accepted, and included in a Docker release 👍 |
Codecov Report
@@ Coverage Diff @@
## master #38570 +/- ##
=========================================
Coverage ? 36.64%
=========================================
Files ? 608
Lines ? 45189
Branches ? 0
=========================================
Hits ? 16561
Misses ? 26343
Partials ? 2285 |
wsong
approved these changes
Jan 16, 2019
Monitoring systems and load balancers are usually configured to use HEAD
requests for health monitoring. The /_ping endpoint currently does not
support this type of request, which means that those systems have fallback
to GET requests.
This patch adds support for HEAD requests on the /_ping endpoint.
Although optional, this patch also returns `Content-Type` and `Content-Length`
headers in case of a HEAD request; Refering to RFC 7231, section 4.3.2:
The HEAD method is identical to GET except that the server MUST NOT
send a message body in the response (i.e., the response terminates at
the end of the header section). The server SHOULD send the same
header fields in response to a HEAD request as it would have sent if
the request had been a GET, except that the payload header fields
(Section 3.3) MAY be omitted. This method can be used for obtaining
metadata about the selected representation without transferring the
representation data and is often used for testing hypertext links for
validity, accessibility, and recent modification.
A payload within a HEAD request message has no defined semantics;
sending a payload body on a HEAD request might cause some existing
implementations to reject the request.
The response to a HEAD request is cacheable; a cache MAY use it to
satisfy subsequent HEAD requests unless otherwise indicated by the
Cache-Control header field (Section 5.2 of [RFC7234]). A HEAD
response might also have an effect on previously cached responses to
GET; see Section 4.3.5 of [RFC7234].
With this patch applied, either `GET` or `HEAD` requests work; the only
difference is that the body is empty in case of a `HEAD` request;
curl -i --unix-socket /var/run/docker.sock http://localhost/_ping
HTTP/1.1 200 OK
Api-Version: 1.40
Cache-Control: no-cache, no-store, must-revalidate
Docker-Experimental: false
Ostype: linux
Pragma: no-cache
Server: Docker/dev (linux)
Date: Mon, 14 Jan 2019 12:35:16 GMT
Content-Length: 2
Content-Type: text/plain; charset=utf-8
OK
curl --head -i --unix-socket /var/run/docker.sock http://localhost/_ping
HTTP/1.1 200 OK
Api-Version: 1.40
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Docker-Experimental: false
Ostype: linux
Pragma: no-cache
Server: Docker/dev (linux)
Date: Mon, 14 Jan 2019 12:34:15 GMT
The client is also updated to use `HEAD` by default, but fallback to `GET`
if the daemon does not support this method.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1d2a15f to
7e7e100
Compare
Member
Author
|
Rebased, to get rid of the commit from #38569 ping @vdemeester @tiborvass @cpuguy83 PTAL 🤗 |
Member
Author
|
Experimental failure ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this one is created on top of #38569; only the last commit is newMonitoring systems and load balancers are usually configured to use
HEADrequests for health monitoring. The
/_pingendpoint currently does notsupport this type of request, which means that those systems have fallback
to
GETrequests.This patch adds support for
HEADrequests on the/_pingendpoint.Although optional, this patch also returns
Content-TypeandContent-Lengthheaders in case of a HEAD request; Refering to RFC 7231, section 4.3.2:
With this patch applied, either
GETorHEADrequests work; the onlydifference is that the body is empty in case of a
HEADrequest;The client is also updated to use
HEADby default, but fallback toGETif the daemon does not support this method.
- Description for the changelog