Skip to content

Commit

Permalink
Merge pull request #58 from joshlemer/remove-StringTokenizer
Browse files Browse the repository at this point in the history
Remove dependence on StringTokenizer
  • Loading branch information
adamw committed Dec 30, 2017
2 parents 0a6ed5d + 990f29c commit fb41715
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions core/src/main/scala/com/softwaremill/sttp/Response.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ package com.softwaremill.sttp
import java.net.HttpCookie
import java.text.SimpleDateFormat
import java.time.ZonedDateTime
import java.util.{
Calendar,
GregorianCalendar,
Locale,
StringTokenizer,
TimeZone
}
import java.util.{Calendar, GregorianCalendar, Locale, TimeZone}

import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
Expand Down Expand Up @@ -75,12 +69,11 @@ object Cookie {
// hand-parsing in such case to preserve the values from the cookie
val lch = h.toLowerCase
val (expires, maxAge) = if (lch.contains("expires=")) {
val tokenizer = new StringTokenizer(h, ";")
val tokens = h.split(";")
var e: Option[ZonedDateTime] = None
var ma: Option[Long] = None

while (tokenizer.hasMoreTokens) {
val t = tokenizer.nextToken()
for (t <- tokens) {
val nv = t.split("=", 2)
if (nv(0).toLowerCase.contains("expires") && nv.length > 1) {
e = expiryDate2ZonedDateTime(nv(1).trim())
Expand Down

0 comments on commit fb41715

Please sign in to comment.