Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart form requests need to use \r\n instead of only \n #74

Closed
ErikPettersson opened this issue Jun 26, 2014 · 3 comments · Fixed by #148
Closed

Multipart form requests need to use \r\n instead of only \n #74

ErikPettersson opened this issue Jun 26, 2014 · 3 comments · Fixed by #148
Assignees
Labels
Context: validation apiaryio/gavel.js et. al

Comments

@ErikPettersson
Copy link

Both multiparty and parted (nodejs body parsing middlewares) do not accept Dredd generated multiform posts, due to line endings not being OK.

It seems they should be \r\n and Dredd always sends \n (perhaps because API Blueprint only supports that, so that's the actual data it's told to send).

So, feature request:
Dredd should make sure that the request are formatted decently. (:

Example request:

+ Request (multipart/form-data;boundary=---BOUNDARY)
    + Headers

            Authorization: qwertyqwerty

    + Body

            ---BOUNDARY
            Content-Disposition: form-data; name="json"


            {"name":"test"}
            ---BOUNDARY
            Content-Disposition: form-data; name="image"; filename="filename.jpg"
            Content-Type: image/jpeg

            data
            ---BOUNDARY--

(See also: apiaryio/api-blueprint#100)

@netmilk
Copy link
Contributor

netmilk commented Jul 1, 2014

Hi, I think this is more Snowcrash and Blueprint related issue then issue of Dredd itself. Bodies for both request and response are taken from the parser AST as they are. I think it will be solved in the future by possibility to submit raw binary blobs as assets of the blueprint. But please refer to the api-blueprint documentation project.

@netmilk
Copy link
Contributor

netmilk commented Jul 1, 2014

Hi, I'm reopening it. I actually realised that Dredd can identify the multipart media type and add proper line endings to the request.

@netmilk netmilk reopened this Jul 1, 2014
@ErikPettersson
Copy link
Author

Hey,

I've also commented on the Blueprint project (apiaryio/api-blueprint#100), but that also includes syntax additions to keep things a bit sparser.

rikardq pushed a commit to rikardq/dredd that referenced this issue Nov 7, 2014
Added function that replaces line feeds \n with carriage return \r in body. It also recalcultes the content length header.
rikardq pushed a commit to rikardq/dredd that referenced this issue Nov 7, 2014
@netmilk netmilk self-assigned this Feb 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Context: validation apiaryio/gavel.js et. al
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants