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

In the HTTP code snippet generator multipart/form-data boundaries are wrong #11084

Closed
1 task done
ValeriyMaslenikov opened this issue Jul 13, 2022 · 1 comment · Fixed by postmanlabs/postman-code-generators#652

Comments

@ValeriyMaslenikov
Copy link

ValeriyMaslenikov commented Jul 13, 2022

Is there an existing issue for this?

  • I have searched the tracker for existing similar issues and I know that duplicates will be closed

Describe the Issue

In a very short way. By the specification for the Content-Type: multipart/form-data we should specify boundary marker. Once this marker is used in the body, it should contain two additional dashes in the beginning of the marker line.

We tried to generate the HTTP Code snippet and we can see that the dashes are not automatically added to the body fields and the last marker should be finished with two dashes, which is also not the part of the snippet code.

Steps To Reproduce

  • Open a new tab
  • Paste some address and select POST method
  • Select "form-data"
  • Add one arbitrary field, e.g. key = foo, value = bar
  • Open code snippet generator
  • Select "HTTP" type

Expected result:

POST / HTTP/1.1
Host: www.google.com
Content-Length: 129
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="foo"

bar
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Actual result:

POST / HTTP/1.1
Host: www.google.com
Content-Length: 124
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="foo"

bar
----WebKitFormBoundary7MA4YWxkTrZu0gW

To prove that it's expected result:

  • select the "javascript - fetch" in the type of the Code Snippet generator
  • open the google.com in the browser
  • open chrome dev console
  • paste the fetch request
  • press "enter" to send the request
  • Open networks tab, find appropriate request in the list of network requests
  • Pay attention to the number of dashes in the content-type (4 of them):
content-type: multipart/form-data; boundary=----WebKitFormBoundaryaS5GsqgYgDVOUdlC

image

- Open "payload" tab of this request - Click on "View source". Pay attention to the number of dashes in the first and last lines:
------WebKitFormBoundaryaS5GsqgYgDVOUdlC
Content-Disposition: form-data; name="foo"

bar
------WebKitFormBoundaryaS5GsqgYgDVOUdlC--

You can see that it contains 6 dashes before boundary marker and two dashes after the last boundary marker.

Screenshots or Videos

No response

Operating System

macOs

Postman Version

9.24.2

Postman Platform

Postman App

Additional Context?

No response

@ValeriyMaslenikov ValeriyMaslenikov changed the title In the HTTP code snippet generator multipart/form-data boundaries is wrong In the HTTP code snippet generator multipart/form-data boundaries are wrong Jul 14, 2022
@umeshp7
Copy link
Member

umeshp7 commented Aug 11, 2022

Hey @ValeriyMaslenikov Thank you for the detailed explanation of the issue. We will take this up soon. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants