Skip to content

Commit

Permalink
fix(azure-functions) strip headers that are disallowed by HTTP/2
Browse files Browse the repository at this point in the history
Per https://tools.ietf.org/html/rfc7540#section-8.1.2.2 intermediaries
that proxy HTTP/1.1 responses to HTTP/2 clients should strip certain
headers that do not serve any purpose in HTTP/2. Not stripping these
headers results in a protocol violation for RFC-compliant clients.

See a similar fix for the aws-lambda plugin here:

f2ee98e

From #5

Signed-off-by: Thibault Charbonnier <[email protected]>
  • Loading branch information
Travis Raines authored and thibaultcha committed Dec 6, 2018
1 parent e75ed26 commit d7dd1d4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kong/plugins/azure-functions/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ end

function azure:access(config)
azure.super.access(self)
local var = ngx.var

-- prepare and store updated config in cache
local conf = conf_cache[config]
Expand Down Expand Up @@ -75,7 +76,7 @@ function azure:access(config)
end
end

local upstream_uri = ngx.var.upstream_uri
local upstream_uri = var.upstream_uri
local path = conf.path
local end1 = path:sub(-1, -1)
local start2 = upstream_uri:sub(1, 1)
Expand Down Expand Up @@ -118,6 +119,14 @@ function azure:access(config)
local response_status = res.status
local response_content = res:read_body()

if var.http2 then
response_headers["Connection"] = nil
response_headers["Keep-Alive"] = nil
response_headers["Proxy-Connection"] = nil
response_headers["Upgrade"] = nil
response_headers["Transfer-Encoding"] = nil
end

ok, err = client:set_keepalive(config.keepalive)
if not ok then
kong.log.err("could not keepalive connection: ", err)
Expand Down

0 comments on commit d7dd1d4

Please sign in to comment.