Skip to content

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

@ValeriyMaslenikov

Description

@ValeriyMaslenikov

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions