Skip to content

Commit 1fe5780

Browse files
committed
Small fix for when robots txt is present but returns nothing
1 parent b52a982 commit 1fe5780

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

server/src/main/java/dev/findfirst/core/service/RobotsFetcher.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ public RobotsTxtResponse getRobotsTxt(String url) {
2626
uri.getFragment());
2727

2828
ResponseEntity<String> robots = rest.getForEntity(robotsUri, String.class);
29+
String text = !robots.getBody().isBlank() ? robots.getBody() : "";
2930

30-
return new RobotsTxtResponse(robots.getStatusCode().value(), robots.getBody().getBytes(),
31+
return new RobotsTxtResponse(robots.getStatusCode().value(),
32+
text.getBytes(),
3133
robots.getHeaders().getContentType() == null ? ""
3234
: robots.getHeaders().getContentType().toString());
3335

3436
} catch (URISyntaxException | HttpClientErrorException ex) {
3537
log.error(ex.toString());
36-
return new RobotsTxtResponse(500, "".getBytes(), "");
38+
return new RobotsTxtResponse(500, ex.toString().getBytes(), "");
3739
}
3840
}
3941

0 commit comments

Comments
 (0)