From efa75dfbb72ba160c17fc6ec27e972828e86da33 Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Tue, 25 Jul 2017 19:30:31 +0300 Subject: [PATCH] Use coma as separator for multi-value headers Fixes: #113 --- api/server/runner.go | 2 +- test/fn-api-tests/exec_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/api/server/runner.go b/api/server/runner.go index 6873d0f6f..571df7281 100644 --- a/api/server/runner.go +++ b/api/server/runner.go @@ -196,7 +196,7 @@ func (s *Server) serve(ctx context.Context, c *gin.Context, appName string, rout // headers for header, value := range c.Request.Header { - envVars[toEnvName("HEADER", header)] = strings.Join(value, " ") + envVars[toEnvName("HEADER", header)] = strings.Join(value, ", ") } cfg := &task.Config{ diff --git a/test/fn-api-tests/exec_test.go b/test/fn-api-tests/exec_test.go index 94f46d103..6cc8206a6 100644 --- a/test/fn-api-tests/exec_test.go +++ b/test/fn-api-tests/exec_test.go @@ -230,6 +230,34 @@ func TestRouteExecutions(t *testing.T) { DeleteRoute(t, s.Context, s.Client, s.AppName, routePath) + routePath = "/os.environ" + image = "denismakogon/os.environ" + routeType = "sync" + CreateRoute(t, s.Context, s.Client, s.AppName, routePath, image, routeType, + s.RouteConfig, s.RouteHeaders) + + t.Run("verify-headers-separator", func(t *testing.T) { + u := url.URL{ + Scheme: "http", + Host: Host(), + } + u.Path = path.Join(u.Path, "r", s.AppName, routePath) + content := &bytes.Buffer{} + output := &bytes.Buffer{} + CallFN(u.String(), content, output, "POST", + []string{ + "ACCEPT: application/xml", + "ACCEPT: application/json; q=0.2", + }) + res := output.String() + if !strings.Contains("application/xml, application/json; q=0.2", res) { + t.Errorf("HEADER_ACCEPT='application/xml, application/json; q=0.2' "+ + "should be in output, have:\n%", res) + } + }) + + DeleteRoute(t, s.Context, s.Client, s.AppName, routePath) + routePath = "/log" image = "funcy/log:0.0.1" routeType = "async"