Skip to content

Commit

Permalink
Fixes url check for w3id (#145)
Browse files Browse the repository at this point in the history
* harvester will stop for fatal errors

* adds accepts header for url check
  • Loading branch information
ndc-dxc authored Oct 18, 2024
1 parent daccb3b commit ad03a4f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
@Slf4j
public class CheckUrlController {

public static final String ACCEPTED_MIME_TYPES =
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,"
+ "image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";

@GetMapping
@SneakyThrows
@Operation(
Expand All @@ -38,6 +42,7 @@ public ResponseEntity<?> check(@RequestParam String url) {
log.info("Checking url {}", url);
HttpURLConnection huc = (HttpURLConnection) new URL(url).openConnection();
huc.setConnectTimeout(5000);
huc.setRequestProperty("Accept", ACCEPTED_MIME_TYPES);
log.info("Response code for url {} is : {}", url, huc.getResponseCode());
return new ResponseEntity<>(HttpStatus.valueOf(huc.getResponseCode()));
}
Expand Down

0 comments on commit ad03a4f

Please sign in to comment.