Skip to content

Commit ad03a4f

Browse files
authored
Fixes url check for w3id (#145)
* harvester will stop for fatal errors * adds accepts header for url check
1 parent daccb3b commit ad03a4f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/it/gov/innovazione/ndc/controller/CheckUrlController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
@Slf4j
2222
public class CheckUrlController {
2323

24+
public static final String ACCEPTED_MIME_TYPES =
25+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,"
26+
+ "image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
27+
2428
@GetMapping
2529
@SneakyThrows
2630
@Operation(
@@ -38,6 +42,7 @@ public ResponseEntity<?> check(@RequestParam String url) {
3842
log.info("Checking url {}", url);
3943
HttpURLConnection huc = (HttpURLConnection) new URL(url).openConnection();
4044
huc.setConnectTimeout(5000);
45+
huc.setRequestProperty("Accept", ACCEPTED_MIME_TYPES);
4146
log.info("Response code for url {} is : {}", url, huc.getResponseCode());
4247
return new ResponseEntity<>(HttpStatus.valueOf(huc.getResponseCode()));
4348
}

0 commit comments

Comments
 (0)