Skip to content

Commit

Permalink
fix(pdk): response.exit accept bytes (#9526)
Browse files Browse the repository at this point in the history
Fix #9294
  • Loading branch information
StarlightIbuki authored Oct 24, 2022
1 parent 3a3efe5 commit cd2bcf9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@
(`kong.request.getUriCaptures`)
[#9512](https://github.com/Kong/kong/pull/9512)

- Fixed parameter type of `kong.service.request.set_raw_body`
(`kong.service.request.setRawBody`), return type of
`kong.service.response.get_raw_body`(`kong.service.request.getRawBody`),
and body parameter type of `kong.response.exit` to bytes. Note that old
version of go PDK is incompatible after this change.
[#9526](https://github.com/Kong/kong/pull/9526)

#### Plugins

- **AWS Lambda**: Fix an issue that is causing inability to
Expand Down
10 changes: 7 additions & 3 deletions kong/include/kong/pluginsocket.proto
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ message String {
string v = 1;
}

message ByteString {
bytes v = 1;
}

message ExitArgs {
int32 status = 1;
string body = 2;
bytes body = 2;
google.protobuf.Struct headers = 3;
}

Expand Down Expand Up @@ -336,10 +340,10 @@ service Kong {
rpc Service_Request_AddHeader(KV) returns (google.protobuf.Empty);
rpc Service_Request_ClearHeader(String) returns (google.protobuf.Empty);
rpc Service_Request_SetHeaders(google.protobuf.Struct) returns (google.protobuf.Empty);
rpc Service_Request_SetRawBody(String) returns (google.protobuf.Empty);
rpc Service_Request_SetRawBody(ByteString) returns (google.protobuf.Empty);

rpc Service_Response_GetStatus(google.protobuf.Empty) returns (Int);
rpc Service_Response_GetHeader(String) returns (String);
rpc Service_Response_GetHeaders(Int) returns (google.protobuf.Struct);
rpc Service_Response_GetRawBody(google.protobuf.Empty) returns (String);
rpc Service_Response_GetRawBody(google.protobuf.Empty) returns (ByteString);
}
2 changes: 2 additions & 0 deletions kong/runloop/plugin_servers/pb_rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ do
[".kong_plugin_protocol.Number"] = unwrap_val,
[".kong_plugin_protocol.Int"] = unwrap_val,
[".kong_plugin_protocol.String"] = unwrap_val,
[".kong_plugin_protocol.ByteString"] = unwrap_val,
[".kong_plugin_protocol.KV"] = function(d)
return d.k, structpb_value(d.v)
end,
Expand Down Expand Up @@ -151,6 +152,7 @@ do
[".kong_plugin_protocol.Number"] = wrap_val,
[".kong_plugin_protocol.Int"] = wrap_val,
[".kong_plugin_protocol.String"] = wrap_val,
[".kong_plugin_protocol.ByteString"] = wrap_val,
[".kong_plugin_protocol.RawBodyResult"] = function(v, err)
if type(v) == "string" then
return { content = v }
Expand Down

0 comments on commit cd2bcf9

Please sign in to comment.