See
Plack::Request methods "parameters" and "uploads". This should be very familiar to you if you know CGI.pm.
Server (this is one line):
plackup -MPlack::Request -MDDP -e'my $app = sub { my ($env) = @_; my $
+req = Plack::Request->new($env); p $req->parameters; p $req->uploads;
+ return [200,[],[]]; };'
Client:
curl -v -F somekey=somevalue -F upload=@somefile http://localhost:5000
HTTP trace:
POST / HTTP/1.1
Host: localhost:5000
User-Agent: curl/7.65.0
Accept: */*
Content-Length: 322
Content-Type: multipart/form-data; boundary=------------------------84
+f03d39abacb4c6
--------------------------84f03d39abacb4c6
Content-Disposition: form-data; name="somekey"
somevalue
--------------------------84f03d39abacb4c6
Content-Disposition: form-data; name="upload"; filename="somefile"
Content-Type: application/octet-stream
somefilecontent
--------------------------84f03d39abacb4c6--
HTTP/1.0 200 OK
Date: Fri, 14 Jun 2019 07:22:11 GMT
Server: HTTP::Server::PSGI
Content-Length: 0
Abbreviated server output:
Hash::MultiValue {
public methods (24) : …
private methods (2) : …
internals: {
somekey "somevalue"
}
}
Hash::MultiValue {
public methods (24) : …
private methods (2) : …
internals: {
upload Plack::Request::Upload
}
}
127.0.0.1 - - [14/Jun/2019:09:22:11 +0200] "POST / HTTP/1.1" 200 0 "-"
+ "curl/7.65.0"