-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] --- Ring request headers are as keywords, instead of downcased strings #3
Comments
Fixes the issue FieryCod#3
Whipped up a quick fix in #4. Seems to work in my project, though I have some other problems there too :D |
Fixes the issue FieryCod#3
Actually, it could also holy-lambda proper would keep the headers map with strings as keys, but not sure what that would cause downstream. |
I do already normalize the headers before an event is sent to AWS. Normalizing input headers is the breaking change, but we can introduce it as an option in the core. If you propose the PR upstream, I will accept it, but please put it under :normalize-headers? flag in h/entrypoint. |
Right, for the core, a flag sounds reasonable for backward compatibility. And we can document the flag too. I was wondering then the holy-lambdaring-adapter. I guess normalizing header keys is a backward breaking change for any current users, though the current users then have a version is does not entirely Ring spec compatible when used with holy-lambda core. Though someone could use this library with another "core" even, that already produces headers that conform to Ring spec. I don't know if this library is used with another "core" though. So thinking that that would it be ok to do header normalization and document it in a changelog, but to warn that this is a breaking change? Or do we just do this in the core :) |
Just do it in the core. It's safer that way. By the way, do you see any other issues with an adapter? |
Yup, I'll see when I'll get to that :)
I haven't run into other issues, at least in the stuff that I used it for now :) I'll report if I run into any other issues. I do though have this middleware that inspects the Ring response content type and if the content type is string-like and the body is a java.io.InputStream, then the body is decoded back to a string. This helps to debug Lambda responses that would otherwise be base64 encoded (and keeps the response size smaller). The alternative would be to originally keep the response body as a string, but that might sometimes be more work, at least initially, depending on what the ring handler or middleware is doing (like metosin/muuntaja gives back java.io.InputStream by default). Not sure if a middleware like this could be part of the adapter by default, but I'd think that one would find that convenient though.
|
Let's optimize it in the adapter. I think it would be better that way. https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types WDYT? |
Yeah, doing this in the adapter would be good for users I think, I just didn't yet have change to propose :) I think |
Exactly. Regarding the content-type we can safely assume the everything that starts from text or contains json,edn,javascript might be represented as a string. |
One thing to be aware of could be the encoding of the InputStream/ByteArray so that the String is created in with the encoding of the bytes. We might want to check the relevant HTTP headers from the response body for the encoding. |
First off, thanks for all the work in this area! I'm really happy about it :)
It seems that when this adapter is used together with the holy-lambda project, because the Lambda input JSON event is parsed as keys being keywordized, in the resulting ring request, the
:headers
is a map with keywords, instead of downcased strings, as in the Ring spec:Here's a sample
prn
of a Ring request from an app that I'm testing the library with:I think this goes unnoticed in the tests, since the tests use a Ring request that has the
:headers
containing valid Ring spec data. I guess there could be a test in this library, that mocks a lambda runtime and uses holy-lambda proper, to make sure a valid ring request is produced, but before that, we probably could have a simpler test that gives the hander a request with sayand makes sure that the adapter converts this into
The text was updated successfully, but these errors were encountered: