You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Philippe Mouawad <ph...@gmail.com> on 2017/03/01 21:36:45 UTC

MultiPart/form-data : Supporting JSON body + file upload

Hello,
Recent JS libraries (Angular + ng-file-upload for example) allow posting a
request with:
- Parameters  that contains JSON
- 1 or more files

See:
https://github.com/danialfarid/ng-file-upload#upload-service

{file: file, info: Upload.jsonBlob({id: id, name: name, ...})} send
fields as json blob, 'application/json' content_type

POST /demo/model HTTP/1.1
Connection: keep-alive
Accept-Language: en-US,en;q=0.5
Cache-Control: no-cache
Accept-Encoding: gzip, deflate
Pragma: no-cache
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0)
Gecko/20100101 Firefox/51.0
Accept: application/json, text/plain, */*
Content-Length: 9145
Content-Type: multipart/form-data;
boundary=cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ; charset=UTF-8
Host: localhost:8081

--cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
Content-Disposition: form-data; name="file"; filename="jmeter.png"
Content-Type: image/png

‰PNG
binary data here .......

--cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
Content-Disposition: form-data; name="info"; filename="dem_modele.json"
*Content-Type: application/json*

{"modelRequestDTO":{"userTranslation":"dfdfdfd","defaultTranslation":"dfdfdfdfd"},"userDescription":"dfdfdfdfdfdf"}
--cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ--



Simulating this in JMeter is not very easy as you need to use the 3rd tab
and put the json body in a file.

This make variabilization of JSON content difficult.

Ideally It would be much better if parameters table could be used,
but it doesn't work as you cannot set Content-Type for parameters.

How could we implement such case in the GUI ?:

- Add a new column that would only be used in some case ? not very
nice? How would we decide wether we use it or not ?

- Create some new Component (ParameterContentTypeSetter) that would
tell HttpRequest the Content-Type of each parameter

by its name ?

- Any other ideas ?

Thanks

Regards

Re: MultiPart/form-data : Supporting JSON body + file upload

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Felix,
Thanks for your answer, unfortunately for now, I don't have a good UI idea
to draw a sketch of it.
The new column seems to be the most simple one and maybe the clearest one.
Regards

On Sun, Apr 30, 2017 at 12:40 PM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Am 19.04.2017 um 22:28 schrieb Philippe Mouawad:
>
>> Hello,
>> Any thoughts on this ?
>>
> No real ideas, sorry. But I think it would be really helpful, if we could
> specify the content-type directly. At the moment we have to use a header
> manager for this, which is not really user friendly.
>
> Could you draw a wireframe sketch of your idea?
>
> Felix
>
> Thanks
>>
>> On Fri, Mar 3, 2017 at 8:08 PM, Philippe Mouawad <
>> philippe.mouawad@gmail.com
>>
>>> wrote:
>>> Hello,
>>> Any idea on this one ?
>>> Thanks
>>>
>>> On Wed, Mar 1, 2017 at 10:36 PM, Philippe Mouawad <
>>> philippe.mouawad@gmail.com> wrote:
>>>
>>> Hello,
>>>> Recent JS libraries (Angular + ng-file-upload for example) allow posting
>>>> a request with:
>>>> - Parameters  that contains JSON
>>>> - 1 or more files
>>>>
>>>> See:
>>>> https://github.com/danialfarid/ng-file-upload#upload-service
>>>>
>>>> {file: file, info: Upload.jsonBlob({id: id, name: name, ...})} send
>>>> fields as json blob, 'application/json' content_type
>>>>
>>>> POST /demo/model HTTP/1.1
>>>> Connection: keep-alive
>>>> Accept-Language: en-US,en;q=0.5
>>>> Cache-Control: no-cache
>>>> Accept-Encoding: gzip, deflate
>>>> Pragma: no-cache
>>>> User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0)
>>>> Gecko/20100101 Firefox/51.0
>>>> Accept: application/json, text/plain, */*
>>>> Content-Length: 9145
>>>> Content-Type: multipart/form-data; boundary=cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ;
>>>> charset=UTF-8
>>>> Host: localhost:8081
>>>>
>>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>>>> Content-Disposition: form-data; name="file"; filename="jmeter.png"
>>>> Content-Type: image/png
>>>>
>>>> ‰PNG
>>>> binary data here .......
>>>>
>>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>>>> Content-Disposition: form-data; name="info"; filename="dem_modele.json"
>>>> *Content-Type: application/json*
>>>>
>>>> {"modelRequestDTO":{"userTranslation":"dfdfdfd","defaultTran
>>>> slation":"dfdfdfdfd"},"userDescription":"dfdfdfdfdfdf"}
>>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ--
>>>>
>>>>
>>>>
>>>> Simulating this in JMeter is not very easy as you need to use the 3rd
>>>> tab
>>>> and put the json body in a file.
>>>>
>>>> This make variabilization of JSON content difficult.
>>>>
>>>> Ideally It would be much better if parameters table could be used,
>>>> but it doesn't work as you cannot set Content-Type for parameters.
>>>>
>>>> How could we implement such case in the GUI ?:
>>>>
>>>> - Add a new column that would only be used in some case ? not very
>>>> nice? How would we decide wether we use it or not ?
>>>>
>>>> - Create some new Component (ParameterContentTypeSetter) that would
>>>> tell HttpRequest the Content-Type of each parameter
>>>>
>>>> by its name ?
>>>>
>>>> - Any other ideas ?
>>>>
>>>> Thanks
>>>>
>>>> Regards
>>>>
>>>>
>>>>
>>> --
>>> Cordialement.
>>> Philippe Mouawad.
>>>
>>>
>>>
>>>
>>
>


-- 
Cordialement.
Philippe Mouawad.

Re: MultiPart/form-data : Supporting JSON body + file upload

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 19.04.2017 um 22:28 schrieb Philippe Mouawad:
> Hello,
> Any thoughts on this ?
No real ideas, sorry. But I think it would be really helpful, if we 
could specify the content-type directly. At the moment we have to use a 
header manager for this, which is not really user friendly.

Could you draw a wireframe sketch of your idea?

Felix

> Thanks
>
> On Fri, Mar 3, 2017 at 8:08 PM, Philippe Mouawad <philippe.mouawad@gmail.com
>> wrote:
>> Hello,
>> Any idea on this one ?
>> Thanks
>>
>> On Wed, Mar 1, 2017 at 10:36 PM, Philippe Mouawad <
>> philippe.mouawad@gmail.com> wrote:
>>
>>> Hello,
>>> Recent JS libraries (Angular + ng-file-upload for example) allow posting
>>> a request with:
>>> - Parameters  that contains JSON
>>> - 1 or more files
>>>
>>> See:
>>> https://github.com/danialfarid/ng-file-upload#upload-service
>>>
>>> {file: file, info: Upload.jsonBlob({id: id, name: name, ...})} send fields as json blob, 'application/json' content_type
>>>
>>> POST /demo/model HTTP/1.1
>>> Connection: keep-alive
>>> Accept-Language: en-US,en;q=0.5
>>> Cache-Control: no-cache
>>> Accept-Encoding: gzip, deflate
>>> Pragma: no-cache
>>> User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
>>> Accept: application/json, text/plain, */*
>>> Content-Length: 9145
>>> Content-Type: multipart/form-data; boundary=cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ; charset=UTF-8
>>> Host: localhost:8081
>>>
>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>>> Content-Disposition: form-data; name="file"; filename="jmeter.png"
>>> Content-Type: image/png
>>>
>>> \u2030PNG
>>> binary data here .......
>>>
>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>>> Content-Disposition: form-data; name="info"; filename="dem_modele.json"
>>> *Content-Type: application/json*
>>>
>>> {"modelRequestDTO":{"userTranslation":"dfdfdfd","defaultTranslation":"dfdfdfdfd"},"userDescription":"dfdfdfdfdfdf"}
>>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ--
>>>
>>>
>>>
>>> Simulating this in JMeter is not very easy as you need to use the 3rd tab
>>> and put the json body in a file.
>>>
>>> This make variabilization of JSON content difficult.
>>>
>>> Ideally It would be much better if parameters table could be used,
>>> but it doesn't work as you cannot set Content-Type for parameters.
>>>
>>> How could we implement such case in the GUI ?:
>>>
>>> - Add a new column that would only be used in some case ? not very nice? How would we decide wether we use it or not ?
>>>
>>> - Create some new Component (ParameterContentTypeSetter) that would tell HttpRequest the Content-Type of each parameter
>>>
>>> by its name ?
>>>
>>> - Any other ideas ?
>>>
>>> Thanks
>>>
>>> Regards
>>>
>>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>


Re: MultiPart/form-data : Supporting JSON body + file upload

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
Any thoughts on this ?
Thanks

On Fri, Mar 3, 2017 at 8:08 PM, Philippe Mouawad <philippe.mouawad@gmail.com
> wrote:

> Hello,
> Any idea on this one ?
> Thanks
>
> On Wed, Mar 1, 2017 at 10:36 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hello,
>> Recent JS libraries (Angular + ng-file-upload for example) allow posting
>> a request with:
>> - Parameters  that contains JSON
>> - 1 or more files
>>
>> See:
>> https://github.com/danialfarid/ng-file-upload#upload-service
>>
>> {file: file, info: Upload.jsonBlob({id: id, name: name, ...})} send fields as json blob, 'application/json' content_type
>>
>> POST /demo/model HTTP/1.1
>> Connection: keep-alive
>> Accept-Language: en-US,en;q=0.5
>> Cache-Control: no-cache
>> Accept-Encoding: gzip, deflate
>> Pragma: no-cache
>> User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
>> Accept: application/json, text/plain, */*
>> Content-Length: 9145
>> Content-Type: multipart/form-data; boundary=cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ; charset=UTF-8
>> Host: localhost:8081
>>
>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>> Content-Disposition: form-data; name="file"; filename="jmeter.png"
>> Content-Type: image/png
>>
>> ‰PNG
>> binary data here .......
>>
>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
>> Content-Disposition: form-data; name="info"; filename="dem_modele.json"
>> *Content-Type: application/json*
>>
>> {"modelRequestDTO":{"userTranslation":"dfdfdfd","defaultTranslation":"dfdfdfdfd"},"userDescription":"dfdfdfdfdfdf"}
>> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ--
>>
>>
>>
>> Simulating this in JMeter is not very easy as you need to use the 3rd tab
>> and put the json body in a file.
>>
>> This make variabilization of JSON content difficult.
>>
>> Ideally It would be much better if parameters table could be used,
>> but it doesn't work as you cannot set Content-Type for parameters.
>>
>> How could we implement such case in the GUI ?:
>>
>> - Add a new column that would only be used in some case ? not very nice? How would we decide wether we use it or not ?
>>
>> - Create some new Component (ParameterContentTypeSetter) that would tell HttpRequest the Content-Type of each parameter
>>
>> by its name ?
>>
>> - Any other ideas ?
>>
>> Thanks
>>
>> Regards
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: MultiPart/form-data : Supporting JSON body + file upload

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
Any idea on this one ?
Thanks

On Wed, Mar 1, 2017 at 10:36 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hello,
> Recent JS libraries (Angular + ng-file-upload for example) allow posting a
> request with:
> - Parameters  that contains JSON
> - 1 or more files
>
> See:
> https://github.com/danialfarid/ng-file-upload#upload-service
>
> {file: file, info: Upload.jsonBlob({id: id, name: name, ...})} send fields as json blob, 'application/json' content_type
>
> POST /demo/model HTTP/1.1
> Connection: keep-alive
> Accept-Language: en-US,en;q=0.5
> Cache-Control: no-cache
> Accept-Encoding: gzip, deflate
> Pragma: no-cache
> User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
> Accept: application/json, text/plain, */*
> Content-Length: 9145
> Content-Type: multipart/form-data; boundary=cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ; charset=UTF-8
> Host: localhost:8081
>
> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
> Content-Disposition: form-data; name="file"; filename="jmeter.png"
> Content-Type: image/png
>
> ‰PNG
> binary data here .......
>
> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ
> Content-Disposition: form-data; name="info"; filename="dem_modele.json"
> *Content-Type: application/json*
>
> {"modelRequestDTO":{"userTranslation":"dfdfdfd","defaultTranslation":"dfdfdfdfd"},"userDescription":"dfdfdfdfdfdf"}
> --cP4hM4kXJ134rNoUFiCCjcKhk4uzVlZAnFYBdQ--
>
>
>
> Simulating this in JMeter is not very easy as you need to use the 3rd tab
> and put the json body in a file.
>
> This make variabilization of JSON content difficult.
>
> Ideally It would be much better if parameters table could be used,
> but it doesn't work as you cannot set Content-Type for parameters.
>
> How could we implement such case in the GUI ?:
>
> - Add a new column that would only be used in some case ? not very nice? How would we decide wether we use it or not ?
>
> - Create some new Component (ParameterContentTypeSetter) that would tell HttpRequest the Content-Type of each parameter
>
> by its name ?
>
> - Any other ideas ?
>
> Thanks
>
> Regards
>
>


-- 
Cordialement.
Philippe Mouawad.