-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Better handling of multipart/form-data requests #747
Comments
#843 is connected to this, we should probably fix it together with this issue. |
New report of the same issues, with attached examples: #984 |
Would be nice if this were fixed. Worked around it with the dummy file, noticed you also have to NOT sully the content-type header when you do this, so I commented out that bit and got this post to execute var systemName = "LoadTestCreatedSystem-"+(Math.random()*0xFFFFFF<<0).toString(8);
res = http.post("https://"+__ENV.HOST+"/api2/accounts/"+locationId+"/systems",
{Name : systemName, GroupCreationCount:"1", TemplateId:"-1", Type:"1", _dummyFile: http.file("", "placeholder")}//,
//{ headers: { "Content-Type": "multipart/form-data" } }
) |
Thanks, @stevegraykcf, we know that this issue is very annoying and we'll try to fix it soon. It's a bit tricky to fix it so k6 behaves consistently and doesn't break users' expectations, but we had a recent discussion about it in this somewhat related pull request, so we now have a somewhat clearer idea how we will proceed with this issue. |
An update about this: multipart requests should be simpler to make now with the Should we close this issue? |
I think so... Though please open an issue in https://github.com/k6io/har-to-k6 to have the converter also use the new |
Forgot to create the issue, but it's being addressed in grafana/har-to-k6#67, so closing this. |
A user asked a question about
multipart/form-data
requests in the slack chat and I found out that users cannot directly makemultipart/form-data
POST requests. The following script produces an invalid request:It seems like it sends
multipart/form-data
as theContent-Type
header, but sends the actual POST data like the request was a normalapplication/x-www-form-urlencoded
HTTP request.We only correctly use send
multipart/form-data
requests when there's a file involved, so as I mentioned in the slack chat, this works as an ugly workaround:It would output something like
multipart/form-data; boundary=some_random_boundary...
. It seems like k6 automatically switches tomultipart/form-data
content-type when there are files involved, so when we try to send a dummy file as well as the username and password it works. And of course users can also manually build the HTTP request body, but it's a huge PITA:Also, when I decided to see how the HAR converter deals with
multipart/form-data
, I saw that it just skips them, so we should fix that as well...The text was updated successfully, but these errors were encountered: