fix(komoot): send explicit GPX accept header for imports
Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>
This commit is contained in:
parent
6bd7ab8748
commit
84735594f2
2 changed files with 10 additions and 5 deletions
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue