diff --git a/modules/aggregator/docs/aggregator.txt b/modules/aggregator/docs/aggregator.txt
index fdef423c7e556ae4234ac8e460f1ba5dc62a6dce..bff3c31cefb4179f7bb42ddb442c129e2da359cd 100644
--- a/modules/aggregator/docs/aggregator.txt
+++ b/modules/aggregator/docs/aggregator.txt
@@ -84,8 +84,8 @@ The endpoint supports the following query parameter:
 `exclude`
 : Specify a `tag` that will be excluded from the metadata set. Useful for leaving out your own federation metadata.
 
-`format`
-: Select the Mime-Type that will be used. Can be `txt` or `xml`.
+`mimetype`
+: Select the Mime-Type that will be used. Default is `application/samlmetadata+xml`.
 
 
 
diff --git a/modules/aggregator/templates/list.php b/modules/aggregator/templates/list.php
index d9ab524125f4d5961236f741f24c55188fe66c4d..47362c2c20fbcfecb5de839a7654bff748093bc6 100644
--- a/modules/aggregator/templates/list.php
+++ b/modules/aggregator/templates/list.php
@@ -15,8 +15,8 @@ if (count($this->data['sources']) === 0) {
 		$encName = htmlspecialchars($source);
 		echo('<li>');
 		echo('<a href="?id=' . $encId . '">' . $encName . '</a>');
-		echo(' <a href="?id=' . $encId . '&amp;format=txt">[' . $this->t('{aggregator:aggregator:text}') . ']</a>');
-		echo(' <a href="?id=' . $encId . '&amp;format=xml">[xml]</a>');
+		echo(' <a href="?id=' . $encId . '&amp;mimetype=text/plain">[' . $this->t('{aggregator:aggregator:text}') . ']</a>');
+		echo(' <a href="?id=' . $encId . '&amp;mimetype=application/xml">[xml]</a>');
 		echo('</li>');
 	}
 
@@ -24,4 +24,3 @@ if (count($this->data['sources']) === 0) {
 }
 
 $this->includeAtTemplateBase('includes/footer.php');
-?>
\ No newline at end of file
diff --git a/modules/aggregator/www/arp.php b/modules/aggregator/www/arp.php
index 4f7ca12161aa50f8857d87de4cafef941effabce..3c05d225e8f708609c28e1497d728c2c9c9948b0 100644
--- a/modules/aggregator/www/arp.php
+++ b/modules/aggregator/www/arp.php
@@ -15,7 +15,7 @@ if (!array_key_exists('id', $_GET)) {
 	exit;
 }
 $id = $_GET['id'];
-if (!in_array($id, $aggregators->getOptions())) 
+if (!in_array($id, $aggregators->getOptions()))
 	throw new SimpleSAML_Error_NotFound('No aggregator with id ' . var_export($id, TRUE) . ' found.');
 
 $aConfig = $aggregators->getConfigItem($id);
@@ -23,10 +23,10 @@ $aConfig = $aggregators->getConfigItem($id);
 
 $aggregator = new sspmod_aggregator_Aggregator($gConfig, $aConfig, $id);
 
-if (isset($_REQUEST['set'])) 
+if (isset($_REQUEST['set']))
 	$aggregator->limitSets($_REQUEST['set']);
 
-if (isset($_REQUEST['exclude'])) 
+if (isset($_REQUEST['exclude']))
 	$aggregator->exclude($_REQUEST['exclude']);
 
 
@@ -66,18 +66,21 @@ if ($aggregator->shouldSign()) {
 	$signer->sign($firstelement, $firstelement, $firstelement->firstChild);
 }
 
-$format = 'application/samlmetadata+xml';
+$mimetype = 'application/samlmetadata-xml';
+$allowedmimetypes = array(
+    'text/plain',
+    'application/samlmetadata-xml',
+    'application/xml',
+);
 
-/* Show the metadata. */
-if(array_key_exists('format', $_GET)) {
-	if ($_GET['format'] === "txt") {
-		$format = 'text/plain';
-	}
+if (isset($_GET['mimetype']) && in_array($_GET['mimetype'], $allowedmimetypes)) {
+    $mimetype = $_GET['mimetype'];
 }
 
-header('Content-Type: ' . $format);
-
-echo($xml->saveXML());
+if ($mimetype === 'text/plain') {
+    SimpleSAML_Utilities::formatDOMElement($xml->documentElement);
+}
 
+header('Content-Type: ' . $mimetype);
 
-?>
\ No newline at end of file
+echo($xml->saveXML());
diff --git a/modules/aggregator/www/index.php b/modules/aggregator/www/index.php
index 76c37f7ce66789fa161875936b1eb87fc0b05aea..1b1049ab1e591613d26898f3d5d5a22ad6669cc1 100644
--- a/modules/aggregator/www/index.php
+++ b/modules/aggregator/www/index.php
@@ -15,7 +15,7 @@ if (!array_key_exists('id', $_GET)) {
 	exit;
 }
 $id = $_GET['id'];
-if (!in_array($id, $aggregators->getOptions())) 
+if (!in_array($id, $aggregators->getOptions()))
 	throw new SimpleSAML_Error_NotFound('No aggregator with id ' . var_export($id, TRUE) . ' found.');
 
 $aConfig = $aggregators->getConfigItem($id);
@@ -23,7 +23,7 @@ $aConfig = $aggregators->getConfigItem($id);
 
 $aggregator = new sspmod_aggregator_Aggregator($gConfig, $aConfig, $id);
 
-if (isset($_REQUEST['set'])) 
+if (isset($_REQUEST['set']))
 	$aggregator->limitSets($_REQUEST['set']);
 
 if (isset($_REQUEST['exclude'])) 
@@ -32,19 +32,24 @@ if (isset($_REQUEST['exclude']))
 
 $xml = $aggregator->getMetadataDocument();
 
-$format = 'application/samlmetadata+xml';
+$mimetype = 'application/samlmetadata+xml';
+$allowedmimetypes = array(
+    'text/plain',
+    'application/samlmetadata-xml',
+    'application/xml',
+);
 
-/* Show the metadata. */
-if(array_key_exists('format', $_GET)) {
-	if ($_GET['format'] === "txt") {
-		SimpleSAML_Utilities::formatDOMElement($xml);
-		$format = 'text/plain';
-	}
+if (isset($_GET['mimetype']) && in_array($_GET['mimetype'], $allowedmimetypes)) {
+    $mimetype = $_GET['mimetype'];
+}
+
+if ($mimetype === 'text/plain') {
+    SimpleSAML_Utilities::formatDOMElement($xml);
 }
 
 $metadata = '<?xml version="1.0"?>'."\n".$xml->ownerDocument->saveXML($xml);
 
-header('Content-Type: ' . $format);
+header('Content-Type: ' . $mimetype);
 header('Content-Length: ' . strlen($metadata));
 
 echo $metadata;