Skip to content

Commit

Permalink
UHF-4799: check for xml response
Browse files Browse the repository at this point in the history
  • Loading branch information
rpnykanen committed Mar 16, 2022
1 parent 68189cc commit 94d52ea
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/HttpMiddleware/AssetHttpMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,30 @@ private function isJsonResponse(Response $response) : bool {
return $response->headers->get('content-type') === 'application/json';
}

/**
* Checks for xml type mainly for sitemap.
*
* @param Response $response
* The response.
*
* @return bool
* TRUE if response is XML
*/
private function isXmlResponse(Response $response){
$contentTypes = [
'application/xml',
'application/xml; charset=utf-8'
];
return in_array($response->headers->get('content-type'), $contentTypes);
}

/**
* {@inheritdoc}
*/
public function handle(
Request $request,
$type = self::MASTER_REQUEST,
$catch = TRUE
$type = self::MASTER_REQUEST,
$catch = TRUE
) : Response {
$response = $this->httpKernel->handle($request, $type, $catch);

Expand All @@ -107,6 +124,11 @@ public function handle(
}
return $response;
}

if ($this->isXmlResponse($response)) {
return $response;
}

$content = $this->proxyManager
->processHtml($content, $request);

Expand Down

0 comments on commit 94d52ea

Please sign in to comment.