Skip to content

Commit

Permalink
perf(aws-lambda): cache the index of the array (#9944)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuruidong authored Aug 8, 2023
1 parent adffad4 commit 65deba3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apisix/plugins/aws-lambda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ local function request_processor(conf, ctx, params)

-- computing canonical query string
local canonical_qs = {}
local canonical_qs_i = 0
for k, v in pairs(params.query) do
canonical_qs[#canonical_qs+1] = ngx.unescape_uri(k) .. "=" .. ngx.unescape_uri(v)
canonical_qs_i = canonical_qs_i + 1
canonical_qs[canonical_qs_i] = ngx.unescape_uri(k) .. "=" .. ngx.unescape_uri(v)
end

tab_sort(canonical_qs)
Expand All @@ -132,10 +134,12 @@ local function request_processor(conf, ctx, params)
-- computing canonical and signed headers

local canonical_headers, signed_headers = {}, {}
local signed_headers_i = 0
for k, v in pairs(headers) do
k = k:lower()
if k ~= "connection" then
signed_headers[#signed_headers+1] = k
signed_headers_i = signed_headers_i + 1
signed_headers[signed_headers_i] = k
-- strip starting and trailing spaces including strip multiple spaces into single space
canonical_headers[k] = str_strip(v)
end
Expand Down

0 comments on commit 65deba3

Please sign in to comment.