Open yogeshzairfoil opened 1 year ago
Have you checked the contents of event.headers
to know what is the proper casing? It must be something other than the two you're attempting to access.
@mscdex I logged it. It is lower case
headers: {
...event.headers,
"Content-Type":
event.headers["Content-Type"] || event.headers["content-type"],
}```
I tried updating the string here to have to exactly same case the error is mentioning.
I don't know what to tell you then as event.headers
seems to already have only lowercased header names. The only way you can get the "Missing Content-Type" error is if the headers
object you pass to busboy
is a non-object, null
, or if headers['content-type']
is not a string.
Just to double check, what does typeof event.headers['content-type']
show?
It logs back as string
I really feel there might be something on Busboy's end that is messing this up. I think people still have these problems with lamda functions - saw that when I was going through all the issues here
@mscdex
Well, you'll need to dig into the code and troubleshoot it yourself then because I have no explanation as to why you're receiving that particular error in this case.
It's not a case-sensitivity issue with content-type. The problem seems to be that the cfg.headers['content-type'] statement returns undefined because the headers in the routing endpoint's request are not a plain map. This is because busboy is not getting the value in the form of headers.get('content-type'), but using index brackets. To make it more convenient, it seems like a good idea to ask busboy authors to use headers.get.
In a nutshell, try this:
const simpleHeaders = {};
for (const key of request.headers.keys()) {
simpleHeaders[key] = request.headers.get(key);
}
const busboy = Busboy({ headers: simpleHeaders });
or
const busboy = Busboy({ headers: Object.fromEntries(request.headers) });
I was under the impression that this issues had been resolved but it still persists. I have tried both Camel case and Lower case content-type but none of it works. Here is my code