Skip to content

Commit

Permalink
added feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Affanmir committed Jan 17, 2024
1 parent 0675681 commit 31580c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apisix/plugins/grpc-web.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local DEFAULT_PROXY_CONTENT_TYPE = "application/grpc"
local DEFAULT_CORS_ALLOW_EXPOSE_HEADERS = "grpc-status,grpc-message"

local GRPC_WEB_TRAILER_FRAME_HEADER = string.char(128, 0, 0, 0)
local GRPC_WEB_REQUIRED_TRAILERS_DEFAULT_VALUES = {
local GRPC_WEB_REQ_TRAILERS_DEFAULT = {
["grpc-status"] = "0",
["grpc-message"] = "OK"
}
Expand Down Expand Up @@ -177,7 +177,7 @@ function _M.body_filter(conf, ctx)
if response and string.len(response) ~= 0 then
local headers = ngx.resp.get_headers()
local trailers = " "
for trailer_key, trailer_default_value in pairs(GRPC_WEB_REQUIRED_TRAILERS_DEFAULT_VALUES) do
for trailer_key, trailer_default_value in pairs(GRPC_WEB_REQ_TRAILERS_DEFAULT) do
local trailer_value = headers[trailer_key]

if trailer_value == nil then
Expand Down
3 changes: 2 additions & 1 deletion t/plugin/grpc-web.t
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ Content-Type: application/grpc-web
Access-Control-Allow-Origin: http://test.com
Content-Type: application/grpc-web
=== TEST 11: grpc-web access control expose headers for non grpc servers that don't implement grpc-web
--- request
POST /grpc/web/a6.RouteService/GetRoute
Expand All @@ -239,4 +241,3 @@ Content-Type: application/grpc-web
Access-Control-Allow-Origin: http://test.com
Content-Type: application/grpc-web
Access-Control-Expose-Headers: grpc-status,grpc-message

0 comments on commit 31580c6

Please sign in to comment.