You shouldn't have to set the content-length yourself.
If you use cURL to send an HTTP POST,
it will calculate the content length for you.
If you set the CURLOPT_POSTFIELDS value as an array,
it will automatically submit the request as multipart/form-data and use a boundary.
If you pass a string, it will use application/x-www-form-urlencoded
so make sure you pass a urlencoded string to CURLOPT_POSTFIELDS and
not an array since you want form-urlencoded.