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

Httpin Invalid Media Type #2123

Closed
5 tasks done
KamalAman opened this issue Apr 1, 2019 · 2 comments
Closed
5 tasks done

Httpin Invalid Media Type #2123

KamalAman opened this issue Apr 1, 2019 · 2 comments

Comments

@KamalAman
Copy link

KamalAman commented Apr 1, 2019

What are the steps to reproduce?

Setup a flow with the following configuration with an http in node and http response node

[
    {
        "id": "ebb295ab.e35dd8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "3d6dd12d.e3060e",
        "type": "http in",
        "z": "ebb295ab.e35dd8",
        "name": "Uploads XML documents",
        "url": "/xml_upload",
        "method": "post",
        "upload": false,
        "swaggerDoc": "",
        "x": 450,
        "y": 280,
        "wires": [
            [
                "1df08233.db4f9e"
            ]
        ]
    },
    {
        "id": "1df08233.db4f9e",
        "type": "http response",
        "z": "ebb295ab.e35dd8",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 770,
        "y": 200,
        "wires": []
    }
]

Post the following payload to the server

curl -X POST \
  http://127.0.0.1:1880/api/xml_upload \
  -H 'Content-Type: application/xml; name=123' \
  -d '<Tag><Child></Child></Tag>'

What happens?

500 Internal Server Error - media-typer is unable to handle Content-Types with parameters

What do you expect to happen?

200 OK

Content-Type of application/xml; name=123 should be valid according to RFC 2045, Content-Types should support parameters type "/" subtype *(";" parameter)

An issue has been created with media-typer jshttp/media-typer#9
Consider moving to the better supported content-type npm module for the http in node. https://www.npmjs.com/package/content-type

Please tell us about your environment:

  • Node-RED version: 0.20
  • node.js version: 10
  • npm version: 6.4
  • Platform/OS: OSX
  • Browser: Chrome
@KamalAman
Copy link
Author

KamalAman commented Apr 1, 2019

As media-typer suggested in jshttp/media-typer#9 you should use content-type instead for proper content-type support.

knolleary added a commit that referenced this issue Apr 2, 2019
@knolleary
Copy link
Member

Thanks for the pointer. Have switched over to the content-type module. Will be in 0.20.4 this week.

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

No branches or pull requests

2 participants