Skip to content

Don't set a default filename when sending multipart form #83

@ArtanisCV

Description

@ArtanisCV

Currently grequests always sets a filename when creating a multipart post request https://github.com/levigross/grequests/blob/master/request.go#L312 . This leads to inconsistent behaviors with python's requests.

More specifically, lots of web servers (e.g., go's net/http, python's flask) rely on the existence of 'filename' when parsing a multipart form. If 'filename' exists, the field will be parsed as a file (and put in Request.FormFile, for example); otherwise it will be parsed as a normal value (and put in Request.FormValue, for example).

As grequests always sets a filename, all fields will be parsed as files, while python's requests allows providing non-file fields using syntax like requests.post(xxx, files={'key': (None, json.dumps("{}"), "application/json")}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions