diff --git a/httprl.module b/httprl.module index 1053360..956ff0b 100644 --- a/httprl.module +++ b/httprl.module @@ -417,6 +417,12 @@ function httprl_request($url, $options = array()) { $options['headers']['Content-Length'] = $content_length; } + // Set the Content-Type to application/x-www-form-urlencoded if the data is + // not empty, the Content-Type is not set, and the method is POST. + if ($content_length > 0 && !isset($options['headers']['Content-Type']) && $options['method'] == 'POST') { + $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded'; + } + // If the server URL has a user then attempt to use basic authentication. if (isset($uri['user'])) { $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : ''));