GithubHelp home page GithubHelp logo

form_data's People

Contributors

abotalov avatar alexwayfer avatar fabienchaynes avatar honeyryderchuck avatar ixti avatar janko avatar mathisto avatar mhickman avatar olleolleolle avatar rafbm avatar summera avatar tarcieri avatar ytkg avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

form_data's Issues

Creation of file parts without filename is not supported

RFC 7578 says that filename parameter is not required:

For form data that represents the content of a file, a name for the
file SHOULD be supplied as well, by using a "filename" parameter of
the Content-Disposition header field. The file name isn't mandatory
for cases where the file name isn't available or is meaningless or
private; this might result, for example, when selection or drag-and-
drop is used or when the form data content is streamed directly from
a device.

Currently filename parameter is always included if a part is file.

Custom encoding method

Hi,

I encountered an incompatibility issue in the Twitter gem between http-form_data and simple_oauth. More explanation are given in this issue.

Basically here (http-form_data) and there (simple_oauth) the encoding is not done the same way.
http-form_data uses URI.encode_www_form which uses URI.encode_www_form_component which doesn't convert *, while simple_oauth encodes *. The twitter API requires * to be encoded as explained in this post.

I understand that it's not a bug in http-form_data per se, but would you be OK to merge a PR allowing users of the gem to override the method encoding data in HTTP::FormData::Urlencoded#initialize and provide their own? By default it'd obviously still be ::URI.encode_www_form so it'd be a transparent change.
If it sounds somewhat acceptable to you, I'd be glad to work on something and to submit a PR.

Thanks πŸ™‚

Setting Content-Type is not supported on non-file parts

From RFC 7578:

Each part MAY have an (optional) "Content-Type" header field, which
defaults to "text/plain". If the contents of a file are to be sent,
the file data SHOULD be labeled with an appropriate media type, if
known, or "application/octet-stream".

Setting Content-Type for non-file parts is not currently supported.

Server-side parser.

Per our brief discussion on Twitter @ixti, here is an issue to collect together our progress on a server-side parser for this multipart form-data library. I'll gladly help with this, time allowing.

This will also resolve the following associated issues:

I have functioning server-side parsing code I'm using myself, which is based on danabr/multipart-parser. Rather than just forking that repository I figured we could absorb and continue to maintain whatever we use, as that code is released under MIT.

Are there any objections to that? The last commit on that repository was 3 years back, and the code is all ruby-native.

/cc: @tarcieri, @kenichi

Robust multipart/related support?

Duplicating the issue I opened on http (httprb/http#175), because it seems to be more relevant here:

Apologies if this already exists, but I haven't found any references to it.

Sometimes one needs to send data via multipart/related. This, so far, has been a huge pain in the ass, with almost every other ruby HTTP solution.

Comparatively, other libraries, such as Node.js' request make it downright simple. If we could get something similar to request's level of multipart/related support, it would be awesome. They not only solve the initial issue of crafting multiparts, but they go above and beyond and let you deal with some implementation caveats.

Thanks!

buffer encoding issues

I've been seeing some issues with this gem in jruby, that led me to this snippet here, where I think that some encoding mis-handling might be happening, and wanted to open the discussion before a PR is submitted.

The snippet in question was (in my case) "shadowed" by IO.copy_stream, but the gist of it is:

  • outbuf.to_s.replace("") will return an "UTF-8" string.
  • @bufferis a binary string.
  • outbuf << @buffer will not change the encoding in outbuf (it'll remain "UTF-8").
  • @buffer.length != @buffer.bytesize

I'd like to propose the following changes:

  • all strings (outbuf, @buffer) should be binary (current_io.read(length, @buffer)would anyways convert the buffer to binary if it were another encoding).
  • switch to @buffer.bytesize;
  • switch to use "".b for initialization (because String.new.encoding, String.new("").encoding...).

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.