Bug 60015 - Multipart/form-data works only for POST using HTTPClient4 while it should for PUT, DELETE...
Summary: Multipart/form-data works only for POST using HTTPClient4 while it should for...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 3.0
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER_5.0
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on: 62260
Blocks:
  Show dependency tree
 
Reported: 2016-08-18 14:31 UTC by kaluramghelot89
Modified: 2018-04-05 19:19 UTC (History)
4 users (show)



Attachments
sample jmx test file that we are using (6.52 KB, application/xml)
2016-08-18 14:31 UTC, kaluramghelot89
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kaluramghelot89 2016-08-18 14:31:46 UTC
Created attachment 34160 [details]
sample jmx test file that we are using

Unable to send the file as a multi-part/form data for PUT request using HTTP Sampler with HTTPClient4.
Please find attached a sample jmx test for the same.

The equivalent cURL command for the same is :
curl --proxy http://our_proxyurl -v -4 -k -u username:somepass -X PUT -F "file1=@C:\Users\tempuser\Desktop\temp\myfile.zip" "https://some_servername//some_api/upload?project=projectname"

It works fine with this cURL command. And we receive a proper response.
We have tried using both jMeter v 2.13 and jMeter v 3.0.
Comment 1 Philippe Mouawad 2016-08-18 20:08:22 UTC
Your issue is probably due to a known limitation of HC4 , see Bug 57242.

Can you disable Basic Auth on your server or pass a header (using Header Manager):
Authorization : Basic <base64 encoded version of <username>:<password>>

Can you try this and give feedback ?
Thank you
Comment 2 kaluramghelot89 2016-08-19 07:04:58 UTC
Hi Philippe

We had already tried using the Authorization header as well. Still we were facing the issue. 

I think the actual issue is that in case of PUT method there is no multipart request is being sent, as we do for POST method. And that is what might be causing the actual failure.
Comment 3 Philippe Mouawad 2016-08-19 07:09:04 UTC
(In reply to kaluramghelot89 from comment #2)
> Hi Philippe
> 
> We had already tried using the Authorization header as well. Still we were
> facing the issue. 
> 
> I think the actual issue is that in case of PUT method there is no multipart
> request is being sent, as we do for POST method. And that is what might be
> causing the actual failure.
I don't understand as it works in my test with Http Mirror Server .
Did you try using HttpClient 3.1 ?
Thanks
Comment 4 kaluramghelot89 2016-08-19 12:33:36 UTC
(In reply to Philippe Mouawad from comment #3)
> (In reply to kaluramghelot89 from comment #2)
> > Hi Philippe
> > 
> > We had already tried using the Authorization header as well. Still we were
> > facing the issue. 
> > 
> > I think the actual issue is that in case of PUT method there is no multipart
> > request is being sent, as we do for POST method. And that is what might be
> > causing the actual failure.
> I don't understand as it works in my test with Http Mirror Server .
> Did you try using HttpClient 3.1 ?
> Thanks

We have not tried with HttpClient 3.1.
Although as a work around we are using the above mentioned cURL command using the OS Process Sampler.

And are you sending multiple files with in your request? Also, would you please share the request that gets created when you are testing. 

In our case the request that is getting created is somewhat similar to this:
______________________________________________________________________________
PUT https://somehost/api/upload?project=projectname

PUT data:
<actual file content, not shown here>

[no cookies]

Request Headers:
Connection: keep-alive
Authorization: Basic cnV***************************NQ==
Content-Type: multipart/form-data
Content-Length: 0
Host: somehost
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_101)
______________________________________________________________________________

And what we want is : 
______________________________________________________________________________
PUT /api/upload?project=projectname HTTP/1.1
Host: somehost
Authorization: Basic cnV*****************************NQ==
Cache-Control: no-cache
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename=""
Content-Type: 


------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=""; filename=""
Content-Type: 
______________________________________________________________________________
Comment 5 Nishit 2017-07-14 05:53:54 UTC
any updates on this. We are using jmeter for api testing in our project where we need to upload images using put request and we are not able to test it due to this issue. I am using jmeter 3.2 and in that multipart/form-data check box is disabled for put request.can somebody look into this issue?
Comment 6 Michael Osipov 2018-04-03 14:28:51 UTC
(In reply to Nishit from comment #5)
> any updates on this. We are using jmeter for api testing in our project
> where we need to upload images using put request and we are not able to test
> it due to this issue. I am using jmeter 3.2 and in that multipart/form-data
> check box is disabled for put request.can somebody look into this issue?

I agree, this is an arbirary limitation. It is upto the client to decide to use multipart/form-data with PUT or PATCH, etc. JMeter isn't a browser and shouldn't have this limitation.
Comment 7 UbikLoadPack support 2018-04-05 13:07:39 UTC
This should be fixed within Bug 62260
Comment 8 Philippe Mouawad 2018-04-05 19:11:46 UTC

*** This bug has been marked as a duplicate of bug 62260 ***
Comment 9 Michael Osipov 2018-04-05 19:15:00 UTC
(In reply to Philippe Mouawad from comment #8)
> 
> *** This bug has been marked as a duplicate of bug 62260 ***

This is not duplicate. This ticket depends on 62260. Please mark it as such.
Comment 10 Philippe Mouawad 2018-04-05 19:19:09 UTC
Hello,
Issue is fixed, tests and feedback are very welcome

Thanks