fix(komoot): send explicit GPX accept header for imports

Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>
This commit is contained in:
Marcus Fihlon 2026-04-28 17:10:34 +02:00
parent 6bd7ab8748
commit 84735594f2
Signed by: McPringle
GPG key ID: C6B7F469EE363E1F
2 changed files with 10 additions and 5 deletions

View file

@ -320,14 +320,17 @@ public class KomootImportService {
for (URI candidateUri : candidateUris) {
try {
ResponseEntity<byte[]> response = restTemplate.exchange(
byte[] body = restTemplate.execute(
candidateUri,
HttpMethod.GET,
httpEntity,
byte[].class
request -> request.getHeaders().putAll(httpEntity.getHeaders()),
response -> {
if (response.getBody() == null) {
return null;
}
return response.getBody().readAllBytes();
}
);
byte[] body = response.getBody();
if (body == null || body.length == 0) {
throw new IllegalStateException("Komoot returned an empty GPX response.");
}

View file

@ -270,6 +270,7 @@ class KomootImportServiceTest {
server.expect(once(), requestTo("https://www.komoot.com/api/v007/tours/2880957035.gpx"))
.andExpect(method(HttpMethod.GET))
.andExpect(header(HttpHeaders.AUTHORIZATION, authHeader))
.andExpect(header(HttpHeaders.ACCEPT, "application/gpx+xml, application/xml, text/xml"))
.andRespond(withSuccess("""
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="komoot">
@ -359,6 +360,7 @@ class KomootImportServiceTest {
server.expect(once(), requestTo("https://www.komoot.com/api/v007/tours/2880957036.gpx"))
.andExpect(method(HttpMethod.GET))
.andExpect(header(HttpHeaders.AUTHORIZATION, authHeader))
.andExpect(header(HttpHeaders.ACCEPT, "application/gpx+xml, application/xml, text/xml"))
.andRespond(withSuccess("""
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="komoot">