Is there a lightweight multipart/form-data parser in C or C++? [closed]

混江龙づ霸主 提交于 2019-12-03 02:42:16

问题


I'm looking at integrating multipart form-data parsing in a web server module so that I can relieve backend web applications (often written in dynamic languages) from parsing the multipart data themselves. The multipart grammar (RFC 2046) looks non-trivial and if I implement it by hand a lot of things can go wrong. Is there already a good, lightweight multipart/form-data parser written in C or C++? I'm looking for one with no external dependencies other than the C or C++ standard library. I don't need email attachment handling or buffered I/O classes or a portability runtime or whatever, just multipart/form-data parsing.

Things that I've considered:

  • GMime - depends on glib, so no go.
  • libapreq - too large, depends on APR, badly documented, no unit tests.

I've also looked at writing a parser with Ragel, but I can't figure out how to do it because the grammar is not static: the boundary can change arbitrarily.


回答1:


I know this question is a couple of years old now, but I needed the same and ended up using this:

https://github.com/iafonov/multipart-parser-c




回答2:


Yes, there one. No secret it is my own. Feel free to use it. The link is: MPFDParser. It has no dependencies at all.




回答3:


mimetic claims to support it. I think GNU cgicc may also support it.




回答4:


cgicc supports it... But is written quite badly and relays on entry buffer in memory.




回答5:


this may not answer your question directly, but did you consider hiphop for php from facebook?

it converts your php code to c++ then compiles with g++.

might save you time in writing something on your own.



来源:https://stackoverflow.com/questions/2265038/is-there-a-lightweight-multipart-form-data-parser-in-c-or-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!