From b1996728aaeaa147c2045c8be79373d59ce7117a Mon Sep 17 00:00:00 2001 From: Boaz Shuster Date: Tue, 6 Dec 2016 23:15:27 +0200 Subject: [PATCH] Update docs and code to use application/x-tar in the build API At the "Build image from Dockerfile" section in the API docs the Content-Type header is missing. In addition, some parts in the code are still setting the Content-Type header to application/tar while it was changed to application/x-tar since 16th September 2015. Signed-off-by: Boaz Shuster --- api/swagger.yaml | 4 ++-- client/image_build.go | 2 +- client/image_build_test.go | 4 ++-- client/plugin_create.go | 2 +- docs/api/v1.18.md | 3 ++- docs/api/v1.19.md | 3 ++- docs/api/v1.20.md | 3 ++- docs/api/v1.21.md | 3 ++- docs/api/v1.22.md | 3 ++- docs/api/v1.23.md | 3 ++- docs/api/v1.24.md | 3 ++- pkg/httputils/mimetype.go | 3 +-- 12 files changed, 21 insertions(+), 15 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index c1c6338ee2..70750a5b32 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -4399,8 +4399,8 @@ paths: in: "header" type: "string" enum: - - "application/tar" - default: "application/tar" + - "application/x-tar" + default: "application/x-tar" - name: "X-Registry-Config" in: "header" description: | diff --git a/client/image_build.go b/client/image_build.go index 6fde75dcfd..411d5493ea 100644 --- a/client/image_build.go +++ b/client/image_build.go @@ -29,7 +29,7 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio return types.ImageBuildResponse{}, err } headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) - headers.Set("Content-Type", "application/tar") + headers.Set("Content-Type", "application/x-tar") serverResp, err := cli.postRaw(ctx, "/build", query, buildContext, headers) if err != nil { diff --git a/client/image_build_test.go b/client/image_build_test.go index b9d04f817a..1e18b7bda8 100644 --- a/client/image_build_test.go +++ b/client/image_build_test.go @@ -170,8 +170,8 @@ func TestImageBuild(t *testing.T) { return nil, fmt.Errorf("X-Registry-Config header not properly set in the request. Expected '%s', got %s", buildCase.expectedRegistryConfig, registryConfig) } contentType := r.Header.Get("Content-Type") - if contentType != "application/tar" { - return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/tar', got %s", contentType) + if contentType != "application/x-tar" { + return nil, fmt.Errorf("Content-type header not properly set in the request. Expected 'application/x-tar', got %s", contentType) } // Check query parameters diff --git a/client/plugin_create.go b/client/plugin_create.go index a660ba5733..27954aa573 100644 --- a/client/plugin_create.go +++ b/client/plugin_create.go @@ -12,7 +12,7 @@ import ( // PluginCreate creates a plugin func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { headers := http.Header(make(map[string][]string)) - headers.Set("Content-Type", "application/tar") + headers.Set("Content-Type", "application/x-tar") query := url.Values{} query.Set("name", createOptions.RepoName) diff --git a/docs/api/v1.18.md b/docs/api/v1.18.md index 3b811c1515..7ecde39af9 100644 --- a/docs/api/v1.18.md +++ b/docs/api/v1.18.md @@ -1192,6 +1192,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.18/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1246,7 +1247,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – base64-encoded ConfigFile object **Status codes**: diff --git a/docs/api/v1.19.md b/docs/api/v1.19.md index e35b4f016b..5ec41160a0 100644 --- a/docs/api/v1.19.md +++ b/docs/api/v1.19.md @@ -1236,6 +1236,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.19/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1292,7 +1293,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – base64-encoded ConfigFile object **Status codes**: diff --git a/docs/api/v1.20.md b/docs/api/v1.20.md index 43344e2ec3..4d7ce43bf0 100644 --- a/docs/api/v1.20.md +++ b/docs/api/v1.20.md @@ -1365,6 +1365,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.20/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1425,7 +1426,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON object with the following structure: diff --git a/docs/api/v1.21.md b/docs/api/v1.21.md index fd491947ba..8d0bd6b374 100644 --- a/docs/api/v1.21.md +++ b/docs/api/v1.21.md @@ -1448,6 +1448,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.21/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1514,7 +1515,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON object with the following structure: diff --git a/docs/api/v1.22.md b/docs/api/v1.22.md index 443d18b680..0d4d9b55eb 100644 --- a/docs/api/v1.22.md +++ b/docs/api/v1.22.md @@ -1627,6 +1627,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.22/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1694,7 +1695,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON object with the following structure: diff --git a/docs/api/v1.23.md b/docs/api/v1.23.md index 3618d5a1cd..07e75f55dd 100644 --- a/docs/api/v1.23.md +++ b/docs/api/v1.23.md @@ -1662,6 +1662,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.23/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1730,7 +1731,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON object with the following structure: diff --git a/docs/api/v1.24.md b/docs/api/v1.24.md index 01520bbe8e..05737e7ae6 100644 --- a/docs/api/v1.24.md +++ b/docs/api/v1.24.md @@ -1659,6 +1659,7 @@ Build an image from a Dockerfile **Example request**: POST /v1.24/build HTTP/1.1 + Content-Type: application/x-tar {% raw %} {{ TAR STREAM }} @@ -1727,7 +1728,7 @@ or being killed. **Request Headers**: -- **Content-type** – Set to `"application/tar"`. +- **Content-type** – Set to `"application/x-tar"`. - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON object with the following structure: diff --git a/pkg/httputils/mimetype.go b/pkg/httputils/mimetype.go index d5cf34e4f2..abef9e9e83 100644 --- a/pkg/httputils/mimetype.go +++ b/pkg/httputils/mimetype.go @@ -8,9 +8,8 @@ import ( // MimeTypes stores the MIME content type. var MimeTypes = struct { TextPlain string - Tar string OctetStream string -}{"text/plain", "application/tar", "application/octet-stream"} +}{"text/plain", "application/octet-stream"} // DetectContentType returns a best guess representation of the MIME // content type for the bytes at c. The value detected by