hapi
hapi copied to clipboard
Cannot send `multipart/form-data` after upgrade to 19.x
Support plan
- which support plan is this issue covered by? Community
- is this issue currently blocking your project? (yes/no): no
- is this issue affecting a production system? (yes/no): yes
Context
- node version: 12.13.1
- module version with issue: ^19.0.5
- last module version without issue: ^18.3.1
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
I use the same code for both versions. But the 19.x always response error 415 - Unspported media type . It's working well on 18.x
{
method: 'PUT',
path: '/api/me/avatar',
options: {
handler: controller.updateAvatar,
description: 'Update user avatar',
tags: ['api', 'update user avatar'],
},
},
Here is the sample postman cUrl
curl -X PUT \
http://localhost:3400/api/me/avatar \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 162' \
-H 'Content-Type: multipart/form-data; boundary=--------------------------762515554275272587725335' \
-H 'Host: localhost:3400' \
-H 'Postman-Token: f6f33e9d-75fa-4b60-acfb-78f23174ad50,47fb7c5c-228f-4c3d-8112-c3f99af90489' \
-H 'User-Agent: PostmanRuntime/7.20.1' \
-H 'cache-control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F dsss=sss
What was the result you got?
Error: 415 - Unsupported Media Type
What result did you expect?
200 OK
Reading the release notes can actually help sometimes.
Why would this make this change? That's just annoying.
Because routes accepting multipart are nowadays the exception, not the norm, and accepting it on all the routes can lead to some problems when you're not expecting it. Anyway it's not that hard to reenable it, it's just a default, but I would advise against it.