Skip to content

Commit

Permalink
Requests without an Accept header are not accepted
Browse files Browse the repository at this point in the history
Closes #497
  • Loading branch information
pedroigor authored and jmartisk committed May 26, 2022
1 parent 256194f commit 721bb8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ Optional<String> getBestMatchingMediaType(Stream<String> acceptHeaders) {
}
});

if (tupleList.isEmpty()) {
return Optional.of(TEXT_PLAIN);
}

WTTuple bestMatchTuple = new WTTuple(-1, null);

// Iterate over the list and find the best match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,11 @@ public void testWithMissingPriorityMulti() {
assertThat(res.get()).isEqualTo("application/json");
}

@Test
public void testDefaultMediaTypeWhenAcceptHeaderNotSet() {
Optional<String> res = requestHandler.getBestMatchingMediaType(Stream.empty());
assertThat(res.isPresent()).isTrue();
assertThat(res.get()).isEqualTo("text/plain");
}

}

0 comments on commit 721bb8b

Please sign in to comment.