jshttp / content-type

Create and parse HTTP Content-Type header
MIT License
131 stars 25 forks source link

Also a valid way to present the Content-type header #18

Closed gregz07 closed 3 years ago

gregz07 commented 3 years ago

Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p

Shouldn't work with the newline also ?

dougwilson commented 3 years ago

No. Not only it is not a valid separator for in the header in the spec (RFC 7231), it is not even possible for a newline to be in a HTTP header, as it is used as the separator between HTTP headers.

gregz07 commented 3 years ago

@dougwilson Oh, its cause I'm using web methods from softwareAG, and they set there headers that way, according to this normative

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

And I don't think this has been deprecated, but again, you guys won't ever support this since its not within the regulations of 7231 ?

Thanks for the feedback, appreciate it

dougwilson commented 3 years ago

Hi @gregz07 this module is specifically for parsing the header that is defined in RFC 7231, as noted in the description of this module. There may be other ways to parse, I'm sure even infinite ways. All are valid. But the context of this specific module is just to parse the specific way as defined in RFC 7231.

gregz07 commented 3 years ago

@dougwilson Ok, if u could advise me a bit further.. It's that body-parser (which I realise now you are also a collaborator there xD) uses this library to parse the content-type. Ergo, If I'm to build a proxy in Node that communicates with the integration server inside the web methods framework... I can't use the body-parser library functionalities. I must deal with the headers by myself, at least for this specific case. Do you agree ?

dougwilson commented 3 years ago

The body-parser module parses the HTTP headers that come in as part of a HTTP request. HTTP requests are part of the RFC that this module parses, so it is using the correct parser for it's context. You can always make something different if you need to parse headers that come in from e-mails (which is the RFC you linked to).

gregz07 commented 3 years ago

Thank your for taking your time to explain me all this. Appreciate it!