=htc,htp #16099 remove all special treatment for ISO-8859-1, switch to UTF-8 as default charset everywhere
This commit is contained in:
parent
41ca0522ef
commit
ea7f3ff9fc
4 changed files with 5 additions and 7 deletions
|
|
@ -29,7 +29,7 @@ final case class ContentType(mediaType: MediaType, definedCharset: Option[HttpCh
|
|||
case Some(cs) ⇒ r ~~ mediaType ~~ ContentType.`; charset=` ~~ cs
|
||||
case _ ⇒ r ~~ mediaType
|
||||
}
|
||||
def charset: HttpCharset = definedCharset getOrElse HttpCharsets.`ISO-8859-1`
|
||||
def charset: HttpCharset = definedCharset getOrElse HttpCharsets.`UTF-8`
|
||||
|
||||
def isCharsetDefined = definedCharset.isDefined
|
||||
def noCharsetDefined = definedCharset.isEmpty
|
||||
|
|
@ -42,7 +42,7 @@ final case class ContentType(mediaType: MediaType, definedCharset: Option[HttpCh
|
|||
if (isCharsetDefined) copy(definedCharset = None) else this
|
||||
|
||||
/** Java API */
|
||||
def getDefinedCharset: japi.HttpCharset = definedCharset.getOrElse(null)
|
||||
def getDefinedCharset: japi.HttpCharset = definedCharset.orNull
|
||||
}
|
||||
|
||||
object ContentType {
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ final case class HttpRequest(method: HttpMethod = HttpMethods.GET,
|
|||
def qValueForCharset(charset: HttpCharset, ranges: Seq[HttpCharsetRange] = acceptedCharsetRanges): Float =
|
||||
ranges match {
|
||||
case Nil ⇒ 1.0f // http://tools.ietf.org/html/rfc7231#section-5.3.1
|
||||
case x ⇒ x collectFirst { case r if r matches charset ⇒ r.qValue } getOrElse (if (charset == `ISO-8859-1`) 1f else 0f)
|
||||
case x ⇒ x collectFirst { case r if r matches charset ⇒ r.qValue } getOrElse 0f
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ package headers
|
|||
import akka.parboiled2.util.Base64
|
||||
import akka.http.model.HttpCharsets._
|
||||
import akka.http.util.{ Rendering, ValueRenderable }
|
||||
|
||||
import akka.http.model.japi.JavaMapping.Implicits._
|
||||
|
||||
sealed abstract class HttpCredentials extends japi.headers.HttpCredentials with ValueRenderable {
|
||||
|
|
@ -23,7 +22,7 @@ sealed abstract class HttpCredentials extends japi.headers.HttpCredentials with
|
|||
final case class BasicHttpCredentials(username: String, password: String) extends japi.headers.BasicHttpCredentials {
|
||||
val cookie = {
|
||||
val userPass = username + ':' + password
|
||||
val bytes = userPass.getBytes(`ISO-8859-1`.nioCharset)
|
||||
val bytes = userPass.getBytes(`UTF-8`.nioCharset)
|
||||
Base64.rfc2045.encodeToChar(bytes, false)
|
||||
}
|
||||
def render[R <: Rendering](r: R): r.type = r ~~ "Basic " ~~ cookie
|
||||
|
|
@ -36,7 +35,7 @@ final case class BasicHttpCredentials(username: String, password: String) extend
|
|||
object BasicHttpCredentials {
|
||||
def apply(credentials: String): BasicHttpCredentials = {
|
||||
val bytes = Base64.rfc2045.decodeFast(credentials)
|
||||
val userPass = new String(bytes, `ISO-8859-1`.nioCharset)
|
||||
val userPass = new String(bytes, `UTF-8`.nioCharset)
|
||||
userPass.indexOf(':') match {
|
||||
case -1 ⇒ apply(userPass, "")
|
||||
case ix ⇒ apply(userPass.substring(0, ix), userPass.substring(ix + 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue