Skip to content

Commit

Permalink
Fix: Ensure wildcard MIME types in Accept header default to non-binary
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Nov 9, 2024
1 parent 470143e commit db4d439
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zio-http/jvm/src/test/scala/zio/http/MediaTypeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object MediaTypeSpec extends ZIOHttpSpec {
}
},
test("custom mime type parsing") {
assertTrue(MediaType.parseCustomMediaType("custom/mime").contains(MediaType("custom", "mime")))
assertTrue(MediaType.parseCustomMediaType("custom/mime").contains(MediaType("custom", "mime", binary = true)))
},
test("optional parameter parsing") {
assertTrue(
Expand Down
3 changes: 2 additions & 1 deletion zio-http/shared/src/main/scala/zio/http/MediaType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ object MediaType extends MediaTypes {
if (contentTypeParts.length == 2) {
val subtypeParts = contentTypeParts(1).split(';')
// Default binary to true for unknown types unless they belong to text families
val isBinary = !customMediaType.startsWith("text/") &&
val isBinary = customMediaType != "*/*" &&
!customMediaType.startsWith("text/") &&
!customMediaType.startsWith("application/json") &&
!customMediaType.startsWith("application/xml")
if (subtypeParts.length >= 1) {
Expand Down

0 comments on commit db4d439

Please sign in to comment.