POST / HTTP/1.1Host: foo.comContent-Type: application/x-www-form-urlencodedContent-Length: 13
arg1=val1&arg2=val2
------------------------------------------------------------------------------------------------------
POST /test.html HTTP/1.1 Host: domain.com Content-Type: multipart/form-data;boundary="<boundary_text>"
--boundary_textContent-Disposition: form-data; name="field1"
value1 --boundary_textContent-Disposition: form-data; name="field2"; filename="<filename>"
value2
--boundary_text--
-----------------------------------------------------------------------------------------------------
GET and POST with application/x-www-form-urlencoded type must be url encoded before sending.
base64 converts binary to printible string. Iti s not url encoding. URL encodeng encodes &;?... charters in the vriables. These charcters are used to parse the url and must not be contained in the values of the variables in the url.
application/x-www-form-urlencoded is automatially url decoded by CGI.pm. If the receiver needs to get the undecoded (encoded) data, multipart/form-data must be used.
use LWP::UserAgent;use HTTP::Request;use HTTP::Request::Common;
my $ua = new LWP::UserAgent();
my $res = $ua->request(POST $auth,
Content_Type => 'form-data',
Content => [arg1 => 'val',
,arg2 => 'val2']);
This code will constrcut and send multipart/form-data so that it is not decoded in the receiver