GithubHelp home page GithubHelp logo

multipart-form-data's Introduction

multipart/form-data (RFC2388) parser for OCaml

Build Status docs

This is a parser for structured form data based on Lwt_stream in order to use it with cohttp. You can use it to send POST parameters.

There are two APIs:

  • a high-level one: parse_stream and get_parts. It works for strings, but has some problems with files.
  • a low-level one: parse. It works for well for both strings and files.

multipart-form-data's People

Contributors

bbc2 avatar emillon avatar leonidas-from-xiv avatar nathanreb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

multipart-form-data's Issues

`find_common` can be made more efficient

The current implementation builds a list of prefixes every time and checks if any is a suffix. It is possible to be better, either by precomputing the list of prefixes, or by building a suffix list.

How to tell the size of the file?

Right now we can get the name of a File via Multipart.file_name, and the body via Multipart.file_stream file - how can I get the number of bytes in the file?

Implement multipart-form-data creation

Would be nice to also create multipart-form-data. This is sort of why I became aware of the project (since I first started my own, same-named one, and realized it is silly), so if you don't mind I'd offer to contribute the creation part of it.

`parse_part` dropping any instance of `\r\n`

Took awhile to track this down, but our binary uploads may contain \r\n in the file bodies somewhere, and it looks like Multipart is stripping every instance, leading to invalid files being stored to disk.

It looks like it might be here https://github.com/cryptosense/multipart-form-data/blob/master/lib/multipart.ml#L163 where all of the lines, having been split on \r\n, are simply concatenated together as-is, not restoring the \r\n that was there beforehand (to be clear, we need the bytes 0d0a to be in the final filestream).

I tried a few different hacks, but I'm not very familiar with Lwt_stream, and couldn't quite figure out how best to get it to interpose the streams I need. Any hints on how to make it work?

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.