In a spring boot application a link generate a pdf file.
Link in thymeleaf
<a th:href="@{/printings/bytesttype/compressions}" class="list-group-item list-group-item-action"><span th:text="#{compressions}">Compressions</span></a>
On the controller side
@GetMapping(value = "/printings/bytesttype/compressions")
public ResponseEntity<byte[]> getCompressionsReport() throws IOException, Exception {
return preparePdfReport(samplingFacade.getCompressionToPrint());
}
private ResponseEntity<byte[]> preparePdfReport(byte[] content) throws IOException {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/pdf"));
String fileName = "report.pdf";
headers.setContentDispositionFormData(fileName, fileName);
headers.setCacheControl("no-cache, must-revalidate, post-check=0, pre-check=0");
ResponseEntity<byte[]> response = new ResponseEntity<>(content, headers, HttpStatus.OK);
return response;
}
Actually user click, a request is done.
After another request is done to open with extension
chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/http://localhost:8080/printings/bytesttype/compressions
Is there a way to avoid that?
tried Chrome sends two requests when downloading a PDF (and cancels one of them)
problem still exist