From 1b45fd723959bfc0bac39236a14a9d4502aee1ac Mon Sep 17 00:00:00 2001 From: chnrxn Date: Mon, 28 Aug 2023 14:18:32 +0800 Subject: [PATCH] /_ping handler: return OSType http header The docker client expects to read the OSType header from the `/_ping` response in order to determine the OS type of the server, for example, when running `docker run --device=/dev/fuse ...` https://github.com/moby/moby/blob/master/client/ping.go#L57 Signed-off-by: chnrxn --- pkg/api/handlers/compat/ping.go | 2 ++ test/apiv2/01-basic.at | 1 + 2 files changed, 3 insertions(+) diff --git a/pkg/api/handlers/compat/ping.go b/pkg/api/handlers/compat/ping.go index ce32d9b7c0..94d2099cdd 100644 --- a/pkg/api/handlers/compat/ping.go +++ b/pkg/api/handlers/compat/ping.go @@ -3,6 +3,7 @@ package compat import ( "fmt" "net/http" + "runtime" "github.com/containers/buildah" ) @@ -18,6 +19,7 @@ func Ping(w http.ResponseWriter, r *http.Request) { w.Header().Set("Builder-Version", "") w.Header().Set("Docker-Experimental", "true") w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("OSType", runtime.GOOS) w.Header().Set("Pragma", "no-cache") w.Header().Set("Libpod-Buildah-Version", buildah.Version) diff --git a/test/apiv2/01-basic.at b/test/apiv2/01-basic.at index c4183eda9e..ddb2e6e44b 100644 --- a/test/apiv2/01-basic.at +++ b/test/apiv2/01-basic.at @@ -11,6 +11,7 @@ t GET /libpod/_ping 200 OK t HEAD /libpod/_ping 200 t GET _ping 200 OK +like "$(<$WORKDIR/curl.headers.out)" $'.*\nOstype: ' "#19767 - undocumented part of docker API" t HEAD _ping 200 t GET libpod/_ping 200 OK t HEAD libpod/_ping 200