How to test POST request multipart / form-data

I am trying to find a tool that will allow me to test the multipart / form-data POST request and configure the request. In particular, I want to check for the absence / presence of a semi-colony in the content header:

multipart/form-data; boundary=140f0f40c9f411e19b230800200c9a66

We have a client that does not send half an hour, and our new servlet (using Apache Commons FileUpload) cannot parse the downloaded file. The old version of our servlet uses a different library method to accept / parse the request, and it can parse the file. Until I can prove that the request will be successful by including half a dozen, the owners of the client application do not want to make any changes to it.

I use cURL to run my tests against a servlet, but I cannot configure the query that it generates to exclude a semicolon. I tried the Poster addon for Firefox and Fiddler to generate a POST test request, but they lead to this error:

org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly

Has anyone found a way to successfully test the multipart / form-data POST request with the downloaded file?

+5
source share
1 answer

You can use curlthese libraries to test, here is an example using the POST file multipart / form-data: fooobar.com/questions/89696 / ...

One thing that I like about a command line tool like curl is easy to repeat (in bash, up and in), and you can save the test later.

: , , . , curl raw , . -H --data-binary ( multipart/form-data, CRLF). :

curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------4ebf00fbcf09" --data-binary @test.txt http://localhost:3000/test

-, :

curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------4ebf00fbcf09" -d $'------------------------------4ebf00fbcf09\r\nContent-Disposition: form-data; name="example"\r\n\r\ntest\r\n------------------------------4ebf00fbcf09--\r\n' http://localhost:3000/test

, .

+1

All Articles