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

Support for multipart/mixed and other multipart content types #18

Open
char0n opened this issue Oct 9, 2023 · 4 comments
Open

Support for multipart/mixed and other multipart content types #18

char0n opened this issue Oct 9, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@char0n
Copy link

char0n commented Oct 9, 2023

Could this library theoretically support multipart/mixed and related content types defined in https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa493937(v=exchg.140)?

According to RFC1341, all 'multipart/* content types have identical syntax, they just differ in semantics. Basically all multipart/* content types are identical with multipart/form-data except that within the single boundary, the Content-Disposition header must be omitted.

@char0n
Copy link
Author

char0n commented Oct 9, 2023

Maybe an additional question. What would prevent this library for running in Node.js runtime 12.20.0?

thanks a lot

@octet-stream
Copy link
Owner

Hi. I wasn't planning on support for other multipart subtypes, but will see. I have to read through all of this.

Maybe an additional question. What would prevent this library for running in Node.js runtime 12.20.0?

I aim to keep my libraries aligned to actively supported Node.js' releases (current + LTS), partially because so of the tools I use for development also do so (like AVA, for example).

@octet-stream octet-stream added enhancement New feature or request help wanted Extra attention is needed labels Oct 9, 2023
@char0n
Copy link
Author

char0n commented Oct 9, 2023

Hi. I wasn't planning on support for other multipart subtypes, but will see. I have to read through all of this.

Would be cool to have it. It's very complicated to make such a requests, but with this library introducing minor modifications, it would just be as easily as writing one line of code.

I aim to keep my libraries aligned to actively supported Node.js' releases (current + LTS), partially because so of the tools I use for development also do so (like AVA, for example).

Just checked, and it runs on Node.js 12.20.0 without any issues.

@char0n
Copy link
Author

char0n commented Oct 9, 2023

I've experimented with creating an adapter on top of this library and it works like this:

import {FormDataEncoder} from "form-data-encoder"

const form = new FormData();
form.append('key', 'value');


const encoder = new FormDataEncoder(form);


const body = Array.from(encoder).reduce((bodyParts, uint8Array) => {
  const bodyPart = new TextDecoder().decode(uint8Array.buffer);
  return `${bodyParts}${bodyPart}`;
}, '');

I'll modify the encoder.headers and remove the Content-Disposition header from the resulting body string. But it's inefficient and not really elegant (but get's the job done).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants