Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 3.8.1 #339

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ f7dccf8d205c1d4f9bd5dbbf9680a6b9d175b444

# Scala Steward: Reformat with scalafmt 3.7.17
cc4f48597d3151542ecec3c159159e1793926314

# Scala Steward: Reformat with scalafmt 3.8.1
084144fd6e2c78ee7e3763eace52e9185007175c
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runner.dialect = scala3
version = 3.7.17
version = 3.8.1
maxColumn = 120
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 @@ -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 ;)
Expand Down
37 changes: 18 additions & 19 deletions core/src/main/scala/sttp/model/Part.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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("; ")
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/sttp/model/UriInterpolator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
Loading