Skip to content

Commit

Permalink
Merge pull request #314 from kamilkloch/range-parameters
Browse files Browse the repository at this point in the history
Ignore q parameter in range.
  • Loading branch information
adamw authored Oct 26, 2023
2 parents 6c3a235 + 0aeede3 commit 51a27d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/sttp/model/MediaType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ case class MediaType(
(range.charset == Wildcard || charset.forall(_.equalsIgnoreCase(range.charset))) &&
// #309: when the main or sub types are wildcard, not taking into account the parameters
// #3253 from tapir: checking the parameters only if they are present in the range
(range.mainType == Wildcard || range.subType == Wildcard || range.otherParameters.isEmpty || {
(range.mainType == Wildcard || range.subType == Wildcard || range.otherParameters.isEmpty || (range.otherParameters.size == 1 && range.otherParameters.contains("q")) || {
// the q value needs to be ignored - it has a different purpose
val rangeParametersWithoutQ = range.otherParameters - "q"
// `otherParameters` needs to be fully equal to `range.otherParameters` (ignoring case)
Expand Down
1 change: 1 addition & 0 deletions core/src/test/scala/sttp/model/MediaTypeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MediaTypeTests extends AnyFlatSpec with Matchers with TableDrivenPropertyC
(MediaType.ApplicationJson, ContentTypeRange("application", "json", "*", EmptyParameters), true),
// the q parameter in the range should be ignored
(MediaType.ApplicationJson, ContentTypeRange("application", "json", "*", Map("q" -> "0.5")), true),
(MediaType.ApplicationJson.copy(otherParameters = Map("a" -> "1")), ContentTypeRange("application", "json", "*", Map("q" -> "0.5")), true),
// range defines parameters, but they are not equal (ignoring case)
(MediaType.ApplicationJson, ContentTypeRange("application", "json", "*", Map("a" -> "1")), false),
(
Expand Down

0 comments on commit 51a27d2

Please sign in to comment.