jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: MultiPart/form-data : Supporting JSON body + file upload
Date Fri, 03 Mar 2017 19:08:39 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message