Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import pekko.annotation.InternalApi
import pekko.http.impl.engine.http2.RequestParsing._
import pekko.http.impl.engine.parsing.HttpHeaderParser
import pekko.http.impl.engine.server.HttpAttributes
import pekko.http.impl.util._
import pekko.http.scaladsl.model
import pekko.http.scaladsl.model._
import pekko.http.scaladsl.model.headers.`Tls-Session-Info`
Expand Down Expand Up @@ -102,7 +103,7 @@ private[http2] object ResponseParsing {
rec(remainingHeaders.tail, status, contentType, contentLengthValue, seenRegularHeader, headers)
} else malformedRequest("HTTP message must not contain more than one content-length header")

case (name, _) if name.startsWith(":") =>
case (name, _) if name.startsWith(':') =>
malformedRequest(s"Unexpected pseudo-header '$name' in response")

case (_, httpHeader: HttpHeader) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ package org.apache.pekko.http.impl.model.parser
import scala.collection.immutable.TreeMap

import org.apache.pekko
import org.parboiled2.Parser
import pekko.http.scaladsl.model.headers._
import pekko.http.impl.util.ISO88591
import pekko.http.impl.util.UTF8
import pekko.http.impl.util._
import pekko.http.impl.model.parser.CharacterClasses.`attr-char`
import pekko.http.impl.model.parser.CharacterClasses.HEXDIG
import pekko.http.scaladsl.model.Uri
import org.parboiled2.Parser

import java.nio.charset.Charset

Expand Down Expand Up @@ -58,7 +57,7 @@ private[parser] trait ContentDispositionHeader { this: Parser with CommonRules w
| `ext-token` ~ ws('=') ~ `ext-value`)

def `ext-token` = rule { // token which ends with '*'
token ~> (s => test(s.endsWith("*")) ~ push(s))
token ~> (s => test(s.endsWith('*')) ~ push(s))
}

// https://tools.ietf.org/html/rfc5987#section-3.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

package org.apache.pekko.http.impl

import language.implicitConversions
import java.nio.charset.StandardCharsets

import com.typesafe.config.Config
import org.apache.pekko
import pekko.stream.scaladsl.Source
import pekko.stream.stage._

import language.implicitConversions
import scala.concurrent.duration.Duration
import scala.concurrent.{ Await, Future }
import scala.reflect.ClassTag
import scala.util.{ Failure, Success }
import scala.util.matching.Regex
import pekko.util.ByteString

import com.typesafe.config.Config
import org.apache.pekko
import pekko.actor._
import pekko.http.impl.engine.parsing.ParserOutput.RequestStart
import pekko.http.scaladsl.model.{ HttpEntity, HttpRequest, HttpResponse }
import pekko.stream.scaladsl.Source
import pekko.stream.stage._
import pekko.util.ByteString

package object util {
private[http] val UTF8 = StandardCharsets.UTF_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ final case class `Content-Disposition`(dispositionType: ContentDispositionType,
case (k, v) if k == "filename" =>
r ~~ "; " ~~ k ~~ '=' ~~ '"'
r.putReplaced(v, keep = safeChars, placeholder = '?') ~~ '"'
case (k, v) if k.endsWith("*") =>
case (k, v) if k.endsWith('*') =>
r ~~ "; " ~~ k ~~ '=' ~~ "UTF-8''"
UriRendering.encode(r, v, UTF8, keep = `attr-char`, replaceSpaces = false)
case (k, v) => r ~~ "; " ~~ k ~~ '=' ~~#! v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ trait FileAndResourceDirectives {
*/
def getFromResource(
resourceName: String, contentType: ContentType, classLoader: ClassLoader = _defaultClassLoader): Route =
if (!resourceName.endsWith("/"))
if (!resourceName.endsWith('/'))
get {
Option(classLoader.getResource(resourceName)).flatMap(ResourceFile.apply) match {
case Some(ResourceFile(url, length, lastModified)) =>
Expand Down Expand Up @@ -222,7 +222,7 @@ object FileAndResourceDirectives extends FileAndResourceDirectives {
RangeDirectives.withRangeSupport &
CodingDirectives.withPrecompressedMediaTypeSupport

private def withTrailingSlash(path: String): String = if (path.endsWith("/")) path else path + '/'
private def withTrailingSlash(path: String): String = if (path.endsWith('/')) path else path + '/'

/**
* Given a base directory and a (Uri) path, returns a path to a location contained in the base directory,
Expand Down