Skip to content

Commit 2769f97

Browse files
committed
Remove support to toggle response buffering
Turning off proxy_buffering seems like a bad practice so this commit is to remove response buffering support from the policy
1 parent 9d1cc0d commit 2769f97

File tree

6 files changed

+3
-66
lines changed

6 files changed

+3
-66
lines changed

gateway/conf.d/apicast.conf

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,6 @@ location @upstream {
8484
header_filter_by_lua_block { require('apicast.executor'):header_filter() }
8585
}
8686

87-
location @upstream_unbuffered {
88-
internal;
89-
90-
rewrite_by_lua_block {
91-
require('resty.ctx').apply()
92-
}
93-
94-
proxy_request_buffering off;
95-
proxy_buffering off;
96-
{% include "conf.d/upstream_shared.conf" %}
97-
98-
# these are duplicated so when request is redirected here those phases are executed
99-
post_action @out_of_band_authrep_action;
100-
body_filter_by_lua_block { require('apicast.executor'):body_filter() }
101-
header_filter_by_lua_block { require('apicast.executor'):header_filter() }
102-
}
103-
10487
location @upstream_request_unbuffered {
10588
internal;
10689

@@ -117,22 +100,6 @@ location @upstream_request_unbuffered {
117100
header_filter_by_lua_block { require('apicast.executor'):header_filter() }
118101
}
119102

120-
location @upstream_response_buffering {
121-
internal;
122-
123-
rewrite_by_lua_block {
124-
require('resty.ctx').apply()
125-
}
126-
127-
proxy_buffering off;
128-
{% include "conf.d/upstream_shared.conf" %}
129-
130-
# these are duplicated so when request is redirected here those phases are executed
131-
post_action @out_of_band_authrep_action;
132-
body_filter_by_lua_block { require('apicast.executor'):body_filter() }
133-
header_filter_by_lua_block { require('apicast.executor'):header_filter() }
134-
}
135-
136103
location / {
137104
set $cached_key '';
138105
set $credentials '';

gateway/src/apicast/policy/buffering/apicast-policy.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
3-
"name": "3scale Request/Response buffering",
4-
"summary": "Controls how 3scale buffer request/response",
3+
"name": "3scale Request buffering",
4+
"summary": "Controls how 3scale buffer request",
55
"description": [
6-
"Configures the buffering for request and response"
6+
"Configures the buffering for request"
77
],
88
"version": "builtin",
99
"configuration": {
@@ -13,11 +13,6 @@
1313
"description": "Request Buffering mode",
1414
"type": "boolean",
1515
"default": true
16-
},
17-
"response_buffering": {
18-
"description": "Response Buffering mode",
19-
"type": "boolean",
20-
"default": true
2116
}
2217
}
2318
}

gateway/src/apicast/policy/buffering/buffering.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ local new = _M.new
1212
function _M.new(config)
1313
local self = new(config)
1414
self.request_buffering = config.request_buffering
15-
self.response_buffering = config.response_buffering
1615
return self
1716
end
1817

1918
function _M:export()
2019
return {
2120
request_buffering = self.request_buffering,
22-
response_buffering = self.response_buffering
2321
}
2422
end
2523

gateway/src/apicast/upstream.lua

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,8 @@ local function get_upstream_location_name(context)
215215
return context.upstream_location_name
216216
end
217217
if context.request_buffering == false then
218-
if context.response_buffering == false then
219-
return "@upstream_unbuffered"
220-
end
221218
return "@upstream_request_unbuffered"
222219
end
223-
if context.response_buffering == false then
224-
return "@upstream_response_unbuffered"
225-
end
226220
end
227221

228222
--- Execute the upstream.

spec/policy/buffering/buffering_spec.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@ describe('Buffering policy', function()
77
local exported = policy:export()
88

99
assert.same(true, exported.request_buffering)
10-
assert.same(true, exported.response_buffering)
1110
end)
1211

1312
it('accepts configuration', function()
1413
local config_buffering = {
1514
request_buffering = false,
16-
response_buffering = false,
1715
}
1816
local policy = BufferingPolicy.new(config_buffering)
1917
local exported = policy:export()
2018

2119
assert.same(false, exported.request_buffering)
22-
assert.same(false, exported.response_buffering)
2320
end)
2421
end)
2522
end)

spec/upstream_spec.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,9 @@ describe('Upstream', function()
220220
it('executes the upstream location when request_buffering provided in the context', function()
221221
local contexts = {
222222
["buffered_request"] = {ctx={request_buffering=true}, upstream_location="@upstream"},
223-
["buffered_response"] = {ctx={response_buffering=true}, upstream_location="@upstream"},
224223
["unbuffered_request"] = {ctx={request_buffering=false}, upstream_location="@upstream_request_unbuffered"},
225-
["unbuffered_response"] = {ctx={response_buffering=false}, upstream_location="@upstream_response_unbuffered"},
226-
["unbuffered"] = {ctx={request_buffering=false, response_buffering=false}, upstream_location="@upstream"},
227224
["upstream_location and buffered_request"] = {ctx={upstream_location_name="@grpc", request_buffering=true}, upstream_location="@grpc"},
228-
["upstream_location and buffered_response"] = {ctx={upstream_location_name="@grpc", response_buffering=true}, upstream_location="@grpc"},
229225
["upstream_location and unbuffered_request"] = {ctx={upstream_location_name="@grpc", request_buffering=false}, upstream_location="@grpc"},
230-
["upstream_location and unbuffered_response"] = {ctx={upstream_location_name="@grpc", response_buffering=false}, upstream_location="@grpc"},
231-
["upstream_location and unbuffered"] = {ctx={upstream_location_name="@grpc", request_buffering=false, response_buffering=false}, upstream_location="@grpc"}
232226
}
233227

234228
for _, value in pairs(contexts) do
@@ -239,14 +233,6 @@ describe('Upstream', function()
239233
end
240234
end)
241235

242-
it('executes the upstream location when response_buffering provided in the context', function()
243-
local upstream = Upstream.new('http://localhost')
244-
245-
upstream:call({response_buffering=true})
246-
247-
assert.spy(ngx.exec).was_called_with("@upstream")
248-
end)
249-
250236
it('skips executing the upstream location when missing', function()
251237
local upstream = Upstream.new('http://localhost')
252238
upstream.location_name = nil

0 commit comments

Comments
 (0)