Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Multipart request bodies need to use \r\n instead of only \n #401

Open
honzajavorek opened this issue Aug 4, 2017 · 0 comments
Open

Multipart request bodies need to use \r\n instead of only \n #401

honzajavorek opened this issue Aug 4, 2017 · 0 comments

Comments

@honzajavorek
Copy link
Contributor

Multipart request example in API Blueprint results in body asset containing newlines formed by \n only. However, such asset isn't valid and usable as raw HTTP payload, all infrastructure counts with \r\n being in place.

Dredd currently fixes this, but I consider it as a workaround. I think the API Blueprint format should take care of this and to provide user with a correct, raw HTTP representation of a body. I guess if other API description formats support multipart, let's say in some declarative way, or if #100 gets implemented in API Blueprint, the API Elements asset should contain the body with \r\n, not with \n.


Example API Blueprint:

FORMAT: 1A

# Testing 'multipart/form-data' Request API

# POST /data

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

    + Body

            ---BOUNDARY
            Content-Disposition: form-data; name="text"
            Content-Type: text/plain

            test equals to 42
            ---BOUNDARY
            Content-Disposition: form-data; name="json"; filename="filename.json"
            Content-Type: application/json

            {"test": 42}
            ---BOUNDARY--

+ Response 200 (application/json; charset=utf-8)

    + Body

            {"test": "OK"}

Resulting asset:

---BOUNDARY\nContent-Disposition: form-data; name="text"\nContent-Type: text/plain\n\ntest equals to 42\n---BOUNDARY\nContent-Disposition: form-data; name="json"; filename="filename.json"\nContent-Type: application/json\n\n{"test": 42}\n---BOUNDARY--\n

Expected resulting asset:

---BOUNDARY\r\nContent-Disposition: form-data; name="text"\r\nContent-Type: text/plain\r\n\r\ntest equals to 42\r\n---BOUNDARY\r\nContent-Disposition: form-data; name="json"; filename="filename.json"\r\nContent-Type: application/json\r\n\r\n{"test": 42}\r\n---BOUNDARY--\r\n
honzajavorek added a commit to apiaryio/dredd-transactions that referenced this issue Jul 30, 2018
honzajavorek added a commit to apiaryio/dredd-transactions that referenced this issue Jul 30, 2018
This was previously a core part of Dredd. It belongs to Dredd Transactions
though as it's a format-specific bug fix. Ideally, Dredd shouldn't need
to know anything about the specifics of formats, Dredd Transactions
should provide a uniform interface.

apiaryio/api-blueprint#401
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants