Skip to content

Commit

Permalink
fix: multipart header for streaming binary (#2534)
Browse files Browse the repository at this point in the history
* fix: multipart header for streaming binary

* chore: fmt
  • Loading branch information
jgranstrom authored Nov 26, 2023
1 parent 33512bc commit b43dbc4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions zio-http/src/main/scala/zio/http/FormField.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ object FormField {

private[http] def getContentType(ast: Chunk[FormAST]): MediaType =
ast.collectFirst {
case header: FormAST.Header if header.name == "Content-Type" =>
case header: FormAST.Header if header.name.equalsIgnoreCase("Content-Type") =>
MediaType
.forContentType(header.value)
.getOrElse(MediaType.application.`octet-stream`) // Unknown content type defaults to binary
Expand All @@ -200,13 +200,13 @@ object FormField {
)(implicit trace: Trace): ZIO[Any, FormDecodingError, FormField] = {
val extract =
ast.foldLeft((Option.empty[FormAST.Header], Option.empty[FormAST.Header], Option.empty[FormAST.Header])) {
case (accum, header: FormAST.Header) if header.name == "Content-Disposition" =>
case (accum, header: FormAST.Header) if header.name.equalsIgnoreCase("Content-Disposition") =>
(Some(header), accum._2, accum._3)
case (accum, header: FormAST.Header) if header.name == "Content-Type" =>
case (accum, header: FormAST.Header) if header.name.equalsIgnoreCase("Content-Type") =>
(accum._1, Some(header), accum._3)
case (accum, header: FormAST.Header) if header.name == "Content-Transfer-Encoding" =>
case (accum, header: FormAST.Header) if header.name.equalsIgnoreCase("Content-Transfer-Encoding") =>
(accum._1, accum._2, Some(header))
case (accum, _) => accum
case (accum, _) => accum
}

for {
Expand Down

0 comments on commit b43dbc4

Please sign in to comment.