Because you're using a send_request_cgi() to make POST requests.  I'd recommend instead of crafting a string to create your POST request, you can return a hash, and then feed it to the 'vars_post' key in send_request_cgi.  Here's an example of sending a POST request using 'vars_post':

	res  = send_request_cgi({
		'method'    => 'POST',
		'uri'       => normalize_uri(base, 'index.php'),
		'vars_post' => {
			'myUsername' => datastore['USERNAME'],
			'myPassword' => datastore['PASSWORD'],
		}
	})