From 1a40f494169f5209d84b9141a5ca0994782f79d3 Mon Sep 17 00:00:00 2001 From: huanggze Date: Thu, 17 Oct 2019 15:07:29 +0800 Subject: [PATCH] explicate file type Signed-off-by: huanggze --- pkg/apis/logging/v1alpha2/register.go | 2 +- pkg/apis/tenant/v1alpha2/register.go | 2 +- pkg/apiserver/logging/logging.go | 3 ++- pkg/apiserver/tenant/tenant.go | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/apis/logging/v1alpha2/register.go b/pkg/apis/logging/v1alpha2/register.go index 8e89b463..fa4b59d8 100644 --- a/pkg/apis/logging/v1alpha2/register.go +++ b/pkg/apis/logging/v1alpha2/register.go @@ -69,7 +69,7 @@ func addWebService(c *restful.Container) error { Writes(v1alpha2.QueryResult{}). Returns(http.StatusOK, RespOK, v1alpha2.QueryResult{})). Consumes(restful.MIME_JSON, restful.MIME_XML). - Produces(restful.MIME_JSON, restful.MIME_OCTET) + Produces(restful.MIME_JSON, "text/plain") ws.Route(ws.GET("/workspaces/{workspace}").To(logging.LoggingQueryWorkspace). Doc("Query logs against the specific workspace."). diff --git a/pkg/apis/tenant/v1alpha2/register.go b/pkg/apis/tenant/v1alpha2/register.go index df75d8b8..f4a916e1 100644 --- a/pkg/apis/tenant/v1alpha2/register.go +++ b/pkg/apis/tenant/v1alpha2/register.go @@ -179,7 +179,7 @@ func addWebService(c *restful.Container) error { Writes(v1alpha2.Response{}). Returns(http.StatusOK, RespOK, v1alpha2.Response{})). Consumes(restful.MIME_JSON, restful.MIME_XML). - Produces(restful.MIME_JSON, restful.MIME_OCTET) + Produces(restful.MIME_JSON, "text/plain") c.Add(ws) return nil diff --git a/pkg/apiserver/logging/logging.go b/pkg/apiserver/logging/logging.go index f824adbe..39a73e60 100644 --- a/pkg/apiserver/logging/logging.go +++ b/pkg/apiserver/logging/logging.go @@ -162,7 +162,8 @@ func logExport(param v1alpha2.QueryParameters, request *restful.Request, respons return } - response.Header().Set("Content-Type", restful.MIME_OCTET) + response.Header().Set(restful.HEADER_ContentType, "text/plain") + response.Header().Set("Content-Disposition", "attachment") // keep search context alive for 1m param.ScrollTimeout = time.Minute diff --git a/pkg/apiserver/tenant/tenant.go b/pkg/apiserver/tenant/tenant.go index 205e9219..d0f6a35b 100644 --- a/pkg/apiserver/tenant/tenant.go +++ b/pkg/apiserver/tenant/tenant.go @@ -348,7 +348,8 @@ func LogQuery(req *restful.Request, resp *restful.Response) { logging.LoggingQueryCluster(req, resp) default: if operation == "export" { - resp.Header().Set("Content-Type", restful.MIME_OCTET) + resp.Header().Set(restful.HEADER_ContentType, "text/plain") + resp.Header().Set("Content-Disposition", "attachment") resp.Write(nil) } else { resp.WriteAsJson(loggingv1alpha2.QueryResult{Read: new(loggingv1alpha2.ReadResult)}) -- GitLab