Git Product home page Git Product logo

Comments (6)

bnoordhuis avatar bnoordhuis commented on August 28, 2024

It's a reasonable request but I don't think it's possible to implement.

Multipart body parts are separated by a boundary marker that http-parser would need to scan for. The parser doesn't backtrack so a partial false positive could lead to data being dropped, particularly if the message is spread out over several chunks. To illustrate:

HTTP/1.1 200 OK
Content-Type: multipart/mixed; boundary="marker"

---marker
Content-Type: text/plain

foo
---mar<BREAK>quee
bar
---marker--

The <BREAK> here is the chunk boundary. The parser has seen (but not stored!) ---mar in the previous chunk. When it starts parsing the second chunk, it discovers it's not actually parsing a boundary marker but by then it's too late.

from http-parser.

judofyr avatar judofyr commented on August 28, 2024

I'm not suggesting that http-parser would scan for boundaries. On the contrary; I want to scan for boundaries. I would create a new http-parser and only give it this:

Content-Type: text/plain

foo

from http-parser.

bnoordhuis avatar bnoordhuis commented on August 28, 2024

Right, that would be fairly easy to implement but it doesn't seem like there's a need for it. Create a new parser, feed it a trivial HTTP/1.1 200 OK status line, then feed it the multipart body, done.

from http-parser.

pgriess avatar pgriess commented on August 28, 2024

Agreed; closing.

from http-parser.

tdecaluwe avatar tdecaluwe commented on August 28, 2024

Feeding it a status line is indeed a simple workaround, but a bit of a hacky solution. Would you accept a PR for this?

from http-parser.

indutny avatar indutny commented on August 28, 2024

@tdecaluwe I don't think that it is a good idea. Through recent years, we have refactored http-parser pretty significantly internally, and exposing these states will lock us into a particular API just for this use-case.

Sorry, but won't fix.

from http-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.