From d784611664d1e77107276cbef4858ae9423ed6c2 Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 3 Apr 2024 00:17:41 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.1 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index e1fd888e..bc9a8248 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,3 +1,3 @@ runner.dialect = scala3 -version = 3.7.17 +version = 3.8.1 maxColumn = 120 \ No newline at end of file From 084144fd6e2c78ee7e3763eace52e9185007175c Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 3 Apr 2024 00:17:47 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.1 Executed command: scalafmt --non-interactive --- .../src/main/scala/sttp/model/MediaType.scala | 2 +- core/src/main/scala/sttp/model/Part.scala | 37 +++++++++---------- .../scala/sttp/model/UriInterpolator.scala | 6 +-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/core/src/main/scala/sttp/model/MediaType.scala b/core/src/main/scala/sttp/model/MediaType.scala index 05c9695c..7c69cbb0 100644 --- a/core/src/main/scala/sttp/model/MediaType.scala +++ b/core/src/main/scala/sttp/model/MediaType.scala @@ -63,7 +63,7 @@ case class MediaType( def isModel: Boolean = mainType.equalsIgnoreCase("model") - // Cache 'toString' given that it's called in the hot path + // Cache 'toString' given that it's called in the hot path // of request processing to generate headers. private lazy val toStringCache: String = { val sb = new java.lang.StringBuilder(32) // "application/json; charset=utf-8".length == 31 ;) diff --git a/core/src/main/scala/sttp/model/Part.scala b/core/src/main/scala/sttp/model/Part.scala index 46159af8..ffa87034 100644 --- a/core/src/main/scala/sttp/model/Part.scala +++ b/core/src/main/scala/sttp/model/Part.scala @@ -41,28 +41,27 @@ case class Part[+T]( // enumerate all variants so that overload resolution works correctly override def header(h: String): Option[String] = super.header(h) - /** - * Returns the value of the `Content-Disposition` header, which should be used when sending this part in a - * multipart request. - * - * The syntax is specified by [[https://datatracker.ietf.org/doc/html/rfc6266#section-4.1 RFC6266 section 4.1]]. - * For safety and simplicity, disposition parameter values are represented as `quoted-string`, defined in - * [[https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.4 RFC9110 section 5.6.4]]. - * - * `quoted-string` allows usage of visible ASCII characters (`%x21-7E`), except for `"` and `\`, which must be escaped - * with a backslash. Additionally, space and horizontal tab is allowed, as well as octets `0x80-FF` (`obs-data`). - * In practice this means that - while not explicitly allowed - non-ASCII UTF-8 characters are valid - * according to this grammar. Additionally, [[https://datatracker.ietf.org/doc/html/rfc6532#section-3.2 RFC6532]] - * makes it more explicit that non-ASCII UTF-8 is allowed. Control characters are not allowed. - * - * This method makes sure that `"` and `\` are escaped, while leaving possible rejection of forbidden characters to - * lower layers (`sttp` backends). - */ + /** Returns the value of the `Content-Disposition` header, which should be used when sending this part in a multipart + * request. + * + * The syntax is specified by [[https://datatracker.ietf.org/doc/html/rfc6266#section-4.1 RFC6266 section 4.1]]. For + * safety and simplicity, disposition parameter values are represented as `quoted-string`, defined in + * [[https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.4 RFC9110 section 5.6.4]]. + * + * `quoted-string` allows usage of visible ASCII characters (`%x21-7E`), except for `"` and `\`, which must be + * escaped with a backslash. Additionally, space and horizontal tab is allowed, as well as octets `0x80-FF` + * (`obs-data`). In practice this means that - while not explicitly allowed - non-ASCII UTF-8 characters are valid + * according to this grammar. Additionally, [[https://datatracker.ietf.org/doc/html/rfc6532#section-3.2 RFC6532]] + * makes it more explicit that non-ASCII UTF-8 is allowed. Control characters are not allowed. + * + * This method makes sure that `"` and `\` are escaped, while leaving possible rejection of forbidden characters to + * lower layers (`sttp` backends). + */ def contentDispositionHeaderValue: String = { def escape(str: String): String = str.flatMap { - case '"' => "\\\"" + case '"' => "\\\"" case '\\' => "\\\\" - case c => c.toString + case c => c.toString } "form-data; " + dispositionParamsSeq.map { case (k, v) => s"""$k="${escape(v)}"""" }.mkString("; ") } diff --git a/core/src/main/scala/sttp/model/UriInterpolator.scala b/core/src/main/scala/sttp/model/UriInterpolator.scala index fc02d7af..973a5076 100644 --- a/core/src/main/scala/sttp/model/UriInterpolator.scala +++ b/core/src/main/scala/sttp/model/UriInterpolator.scala @@ -731,14 +731,14 @@ object UriInterpolator { case Singleton(ExpressionToken(s: Array[_])) => b ++= s.flatMap(anyToStringOpt) doToSeq(tailTs) - case valueTs if(valueTs.size == 1) => - // This case is equivalent to the next one but optimizes for the + case valueTs if (valueTs.size == 1) => + // This case is equivalent to the next one but optimizes for the // frequent scenario where the sequence contains a single element. valueTs.get(0) match { case StringToken(s) => b += decode(s, decodePlusAsSpace) case ExpressionToken(e) => anyToStringOpt(e).foreach(b += _) case EqInQuery => b += "=" - case _ => + case _ => } doToSeq(tailTs) case valueTs => From 606ffbddc5a9f50051407d4cc3a0113e009a2fdd Mon Sep 17 00:00:00 2001 From: scala-steward Date: Wed, 3 Apr 2024 00:17:47 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.1' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 6a690571..36a2bcae 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,6 @@ f7dccf8d205c1d4f9bd5dbbf9680a6b9d175b444 # Scala Steward: Reformat with scalafmt 3.7.17 cc4f48597d3151542ecec3c159159e1793926314 + +# Scala Steward: Reformat with scalafmt 3.8.1 +084144fd6e2c78ee7e3763eace52e9185007175c