Using Mojolicious, how can I tell on the server side if a request was made like this:
curl -X POST --data-binary "@/home/me/some/file.jpg" \
http://127.0.0.1:3000/tasks/some_task
or like this:
curl -X POST \
-F "userid=1" \
-F "filecomment=This is an image file" \
-F "image=@/home/me/some/filejpg" \
http://127.0.0.1:3000/tasks/some_task
How can I identify differences - I suppose on the Mojo::Request object?
You can't really because the first request makes no sense. It doesn't send a form, but it sends a
Content-Typeheader identifying the content as form data.The first request should use something like the following:
That would allow the server to distinguish based on content type. A form will have a Content-Type
multipart/form-dataorapplication/x-www-form-urlencodedinstead.