Skip to content
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

Missing Content-Type for BusBoy using Azure Function v4 #232

Closed
crizzs opened this issue Mar 11, 2024 · 4 comments
Closed

Missing Content-Type for BusBoy using Azure Function v4 #232

crizzs opened this issue Mar 11, 2024 · 4 comments

Comments

@crizzs
Copy link

crizzs commented Mar 11, 2024

Hello Azure,

I am faced with this issue (missing Content-Type) while using the latest version of busboy on Azure Function v4 to process form data.

Noticed azure function field name is content-type instead of Content-Type. I have no such issue on azure function v3

Screenshot 2024-03-11 at 7 00 40 PM
@crizzs crizzs changed the title Missing Content-Type for BusBoy using Azure Function HttpRequest Object Missing Content-Type for BusBoy using Azure Function v4 Mar 11, 2024
@ejizba
Copy link
Contributor

ejizba commented Mar 12, 2024

Hi @crizzs can you please provide more detailed sample code? In general request headers are supposed to be case-insensitive and I think busboy will handle both casings, so I suspect something else might be causing the problem

@crizzs
Copy link
Author

crizzs commented Mar 13, 2024

Hello ejizba,

This issue is well-publicised under another repository, @anzp/azure-function-multipart (Used them for azure functions v3). BusBoy has an if-statement that is case sensitive. This is designed due to an underlying assumption that all headers automatically lowercases all incoming headers to make them easily accessible.
https://github.com/mscdex/busboy/blob/master/lib/index.js#L52

Issue flagged out by community as well:
anzharip/azure-function-multipart#637

Anyways I found a workaround to get through it by turning the headers back to an object for reprocessing. This will prevent busboy from flagging out the missing Content-Type.

Object.fromEntries(req.headers)

@ejizba
Copy link
Contributor

ejizba commented Mar 14, 2024

Right so I don't think the problem is the casing of content-type, but just the fact that our request.query property is now of type URLSearchParams which doesn't have the headers directly on the object. In other words, request.query['content-type'] doesn't work but request.query.get('content-type') does.

Since busboy expects the headers to be directly on the object, I feel like your workaround Object.fromEntries(req.headers) is the correct/best way to do this.

Btw, if you haven't already, you could try doing request.formData() directly. It's less configurable than busboy, but for simple forms it'll get the job done.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants