-
Notifications
You must be signed in to change notification settings - Fork 70
Bootstrap edits #25
base: development
Are you sure you want to change the base?
Bootstrap edits #25
Conversation
ibejohn818
commented
Jan 17, 2019
- use php built-in query string builder
- lower case on header keys to prevent duplicate keys of differing case
- lower case on header key to prevent duplicate keys of differing case
} | ||
} | ||
} | ||
$uri .= "?" . http_build_query($event['multiValueQueryStringParameters']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this really does the right thing. For example, multiValueQueryStringParameters
might have the following value:
"multiValueQueryStringParameters":{
"name":[
"me"
],
"multivalueName":[
"you",
"me"
]
}
This corresponds to a url querystring like ?name=me&multivalueName=you&multivalueName=me
If you fed the same data into http_build_query
, it would generate the following querystring: ?name[0]=me&multivalueName[0]=you&multivalueName[1]=me
. (The square brackets []
would actually be url-encoded, but I left them unencoded to make it easier to understand here.)
Can you double check my thinking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@txase php requires the square brackets to exist for multiple value query string parameters.
if php parses the query string ?name=me&multivalueName=you&multivalueName=me
you'll end up with:
array(2) { ["multivalueName"]=> string(2) "me" ["name"]=> string(2) "me" }
when you have the square brackets you receive the full array in php:
array(2) { ["multivalueName"]=> array(2) { [0]=> string(3) "you" [1]=> string(2) "me" } ["name"]=> string(2) "me" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be that PHP requires square brackets to exist for multiple value query string parameters, but this layer proxies parameters as they were received by API Gateway from the client. If they aren't in the correct format for PHP to understand them, then the client needs to be fixed to send them correctly.
I don't want to modify requests as they are received and then proxied to and from the PHP webserver.
@@ -191,6 +175,8 @@ while (true) { | |||
return strlen($header); | |||
} | |||
|
|||
$name = strtolower($name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not lose the fidelity of the header name as it passes through the layer. If the API Gateway or ALB can pass it with a specific case, let's leave it as-is.