{"action":"created","issue":{"url":"https://api.github.com/repos/cdent/gabbi/issues/211","repository_url":"https://api.github.com/repos/cdent/gabbi","labels_url":"https://api.github.com/repos/cdent/gabbi/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/cdent/gabbi/issues/211/comments","events_url":"https://api.github.com/repos/cdent/gabbi/issues/211/events","html_url":"https://github.com/cdent/gabbi/issues/211","id":215920495,"number":211,"title":"Support for multipart/form-data encoding","user":{"login":"justanotherdot","id":5350032,"avatar_url":"https://avatars0.githubusercontent.com/u/5350032?v=3","gravatar_id":"","url":"https://api.github.com/users/justanotherdot","html_url":"https://github.com/justanotherdot","followers_url":"https://api.github.com/users/justanotherdot/followers","following_url":"https://api.github.com/users/justanotherdot/following{/other_user}","gists_url":"https://api.github.com/users/justanotherdot/gists{/gist_id}","starred_url":"https://api.github.com/users/justanotherdot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justanotherdot/subscriptions","organizations_url":"https://api.github.com/users/justanotherdot/orgs","repos_url":"https://api.github.com/users/justanotherdot/repos","events_url":"https://api.github.com/users/justanotherdot/events{/privacy}","received_events_url":"https://api.github.com/users/justanotherdot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-22T00:39:53Z","updated_at":"2017-03-23T10:10:00Z","closed_at":null,"body":"`gabbi` supports sending specific binary data as single field by using `data: <@file`, but what would be the best way to replicate `multipart/form-data` requests? Something of the form:\r\n\r\n```yaml\r\ntests:\r\n  - name: multipart/form-data test\r\n    POST: /api/form-data-endpoint\r\n    request_headers:\r\n      content-type: multipart/form-data\r\n    data:\r\n      key: val\r\n      file: <@kittens.png\r\n```\r\nmultipart/form-data isn't entirely possible with the custom content handler approach as it requires modifying the Content-Type to have a boundary section identifier e.g. \r\n\r\n```http\r\nContent-Type: multipart/form-data;boundary=---------------------------735323031399963166993862150\r\n```\r\n\r\nTrying to use fixtures as a hack doesn't work either as the fixtures don't have the test context, afaik. \r\n\r\n**Possible solutions**\r\n\r\n1. Having some facility to plug in arbitrary python test code would be nice, but obviously it would have to \r\n  play nice with the current test harness being used. \r\n\r\n  ```yaml\r\n    - name: multipart/form-data test\r\n      POST: /api/form-data-endpoint\r\n      request_headers:\r\n        content-type: multipart/form-data\r\n      run: extra-tests:multipart_request\r\n  ```\r\n\r\n2. Passing in the context to fixtures: then one can inject test specific checks and run code (e.g. run the \r\n    multipart_request check if test is named `X`. \r\n\r\n3. Implement builtin support for `multipart/form-data` encoding in a form similar to the first example above.\r\n\r\nI've written a small proof of concept for point one but it's overkill for this. Personally I think point three should be the preferred as it should only require some minor changes in `make_one_test` and how `request` handles urrlib3 POSTs with fields given the passed content type, I believe. "},"comment":{"url":"https://api.github.com/repos/cdent/gabbi/issues/comments/288672878","html_url":"https://github.com/cdent/gabbi/issues/211#issuecomment-288672878","issue_url":"https://api.github.com/repos/cdent/gabbi/issues/211","id":288672878,"user":{"login":"cdent","id":34498,"avatar_url":"https://avatars0.githubusercontent.com/u/34498?v=3","gravatar_id":"","url":"https://api.github.com/users/cdent","html_url":"https://github.com/cdent","followers_url":"https://api.github.com/users/cdent/followers","following_url":"https://api.github.com/users/cdent/following{/other_user}","gists_url":"https://api.github.com/users/cdent/gists{/gist_id}","starred_url":"https://api.github.com/users/cdent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdent/subscriptions","organizations_url":"https://api.github.com/users/cdent/orgs","repos_url":"https://api.github.com/users/cdent/repos","events_url":"https://api.github.com/users/cdent/events{/privacy}","received_events_url":"https://api.github.com/users/cdent/received_events","type":"User","site_admin":false},"created_at":"2017-03-23T10:10:00Z","updated_at":"2017-03-23T10:10:00Z","body":"What's I'd prefer to see, if you're in the mood for another pull request, is:\r\n\r\n* changes to gabbi itself that allow another optional arg to `dumps` (with some tests, docs, etc)\r\n* in a separate repo and package: the multipart handler done as an external content handler, in the vein of [gabbihtml](https://github.com/cdent/gabbihtml) (which is not fully completely so probably has some warts). If you're happy to be the maintainer of that, that's great. If not we can do something like start a repo on which we're both collaborators."}}
{"actor":{"display_login":"cdent"}}