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

Provide default values for CookieValueWithMeta #10

Merged
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ core/native/local.sbt

# Scala Native
lowered.hnir

# Bloop / Metals
.bloop/
.metals/
project/metals.sbt
29 changes: 15 additions & 14 deletions core/shared/src/main/scala/sttp/model/Cookie.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,28 @@ object CookieValueWithMeta {
Some(s"Value of directive $directiveName name can contain any characters except ; and control characters")
} else None
}

def unsafeApply(
value: String,
expires: Option[Instant],
maxAge: Option[Long],
domain: Option[String],
path: Option[String],
secure: Boolean,
httpOnly: Boolean,
otherDirectives: Map[String, Option[String]]
expires: Option[Instant] = None,
maxAge: Option[Long] = None,
domain: Option[String] = None,
path: Option[String] = None,
secure: Boolean = false,
httpOnly: Boolean = false,
otherDirectives: Map[String, Option[String]] = Map.empty
): CookieValueWithMeta =
safeApply(value, expires, maxAge, domain, path, secure, httpOnly, otherDirectives).getOrThrow

def safeApply(
value: String,
expires: Option[Instant],
maxAge: Option[Long],
domain: Option[String],
path: Option[String],
secure: Boolean,
httpOnly: Boolean,
otherDirectives: Map[String, Option[String]]
expires: Option[Instant] = None,
maxAge: Option[Long] = None,
domain: Option[String] = None,
path: Option[String] = None,
secure: Boolean = false,
httpOnly: Boolean = false,
otherDirectives: Map[String, Option[String]] = Map.empty
): Either[String, CookieValueWithMeta] = {
Validate.all(
Cookie.validateValue(value),
Expand Down