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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ b6e4bd242e5e5657f2bb17478c98abb06641eeae
8093f01074103e542f12c228c3720f9f9a06a53e
ba209d86f235ad43cf7d5e0eaf941489058c90c8
a904e917d5851ebffc5e1eabbee70cf1685c4263

# Scala Steward: Reformat with scalafmt 3.10.3
245df4a95b09802b6c1ea2dbc429259b368bd0ef
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.17
version = 3.10.3
runner.dialect = scala213
project.git = true
style = defaultWithAlign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ class HttpClientExampleSpec extends AnyWordSpec with Matchers with CompileOnlySp
Source.queue[(HttpRequest, Promise[HttpResponse])](QueueSize)
.via(poolClientFlow)
.to(Sink.foreach {
case ((Success(resp), p)) => p.success(resp)
case ((Failure(e), p)) => p.failure(e)
case (Success(resp), p) => p.success(resp)
case (Failure(e), p) => p.failure(e)
})
.run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class BasicDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {
private def nonSuccessToEmptyJsonEntity(response: HttpResponse): HttpResponse =
response.status match {
case code if code.isSuccess => response
case code =>
case code =>
log.warning("Dropping response entity since response status code was: {}", code)
response.withEntity(NullJsonEntity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec

// tests:
Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~>
route ~> check {
route ~> check {
responseAs[String] shouldEqual "Person: Jane - favorite number: 42"
}
// #example-entity-with-json
Expand All @@ -66,7 +66,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec

// tests:
Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~>
route ~> check {
route ~> check {
responseAs[String] shouldEqual """Person: "Jane" - favorite number: 42"""
}
// #example-entity-with-raw-json
Expand Down Expand Up @@ -115,7 +115,7 @@ class MarshallingDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec

// tests:
Post("/", HttpEntity(`application/json`, """{ "name": "Jane", "favoriteNumber" : 42 }""")) ~>
route ~> check {
route ~> check {
mediaType shouldEqual `application/json`
responseAs[String] should include(""""name":"Jane"""")
responseAs[String] should include(""""favoriteNumber":42""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

val validCredentials = BasicHttpCredentials("John", "p4ssw0rd")
Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "The user is 'John'"
}

val invalidCredentials = BasicHttpCredentials("Peter", "pan")
Get("/secured") ~>
Get("/secured") ~>
addCredentials(invalidCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Unauthorized
responseAs[String] shouldEqual "The supplied authentication is invalid"
header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"),
Expand Down Expand Up @@ -93,20 +93,20 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

val validCredentials = BasicHttpCredentials("John", "p4ssw0rd")
Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "The user is 'John'"
}

val validAdminCredentials = BasicHttpCredentials("John", "p4ssw0rd-special")
Get("/secured") ~> addCredentials(validAdminCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "The user is 'John-admin'"
}

val invalidCredentials = BasicHttpCredentials("Peter", "pan")
Get("/secured") ~>
Get("/secured") ~>
addCredentials(invalidCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Unauthorized
responseAs[String] shouldEqual "The supplied authentication is invalid"
header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"),
Expand Down Expand Up @@ -146,14 +146,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

val validCredentials = BasicHttpCredentials("John", "p4ssw0rd")
Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "The user is 'John'"
}

val invalidCredentials = BasicHttpCredentials("Peter", "pan")
Get("/secured") ~>
Get("/secured") ~>
addCredentials(invalidCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Unauthorized
responseAs[String] shouldEqual "The supplied authentication is invalid"
header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"),
Expand Down Expand Up @@ -193,14 +193,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

val validCredentials = BasicHttpCredentials("John", "p4ssw0rd")
Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "The user is 'John'"
}

val invalidCredentials = BasicHttpCredentials("Peter", "pan")
Get("/secured") ~>
Get("/secured") ~>
addCredentials(invalidCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Unauthorized
responseAs[String] shouldEqual "The supplied authentication is invalid"
header[`WWW-Authenticate`].get.challenges.head shouldEqual HttpChallenge("Basic", Some("secure site"),
Expand Down Expand Up @@ -241,7 +241,7 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

val validCredentials = BasicHttpCredentials("John", "p4ssw0rd")
Get("/secured") ~> addCredentials(validCredentials) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.OK
responseAs[String] shouldEqual "Authenticated!"
}
Expand Down Expand Up @@ -278,14 +278,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {
// tests:
val johnsCred = BasicHttpCredentials("John", "p4ssw0rd")
Get("/peters-lair") ~> addCredentials(johnsCred) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Forbidden
responseAs[String] shouldEqual "The supplied authentication is not authorized to access this resource"
}

val petersCred = BasicHttpCredentials("Peter", "pan")
Get("/peters-lair") ~> addCredentials(petersCred) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "'Peter' visited Peter's lair"
}
// #authorize0-0
Expand Down Expand Up @@ -322,14 +322,14 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {
// tests:
val johnsCred = BasicHttpCredentials("John", "p4ssw0rd")
Get("/peters-lair") ~> addCredentials(johnsCred) ~> // adds Authorization header
route ~> check {
route ~> check {
status shouldEqual StatusCodes.Forbidden
responseAs[String] shouldEqual "The supplied authentication is not authorized to access this resource"
}

val petersCred = BasicHttpCredentials("Peter", "pan")
Get("/peters-lair") ~> addCredentials(petersCred) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "'Peter' visited Peter's lair"
}
// #authorizeAsync0
Expand All @@ -350,7 +350,7 @@ class SecurityDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {
// tests:
val johnsCred = BasicHttpCredentials("John", "p4ssw0rd")
Get("/") ~> addCredentials(johnsCred) ~> // adds Authorization header
route ~> check {
route ~> check {
responseAs[String] shouldEqual "Credentials: Basic Sm9objpwNHNzdzByZA=="
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class WebSocketDirectivesExamplesSpec extends RoutingSpec with CompileOnlySpec {

// WS creates a WebSocket request for testing
WS("/services", wsClient.flow, List("other", "echo")) ~>
websocketMultipleProtocolRoute ~>
websocketMultipleProtocolRoute ~>
check {
expectWebSocketUpgradeWithProtocol { protocol =>
protocol shouldEqual "echo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ object CachingDirectives {

import pekko.http.scaladsl.server.directives.{ CachingDirectives => D }

private implicit def routeResultCacheMapping[K]: JavaMapping[Cache[K, RouteResult], pekko.http.caching.scaladsl.Cache[
private implicit def routeResultCacheMapping[K]: JavaMapping[Cache[K, RouteResult],
pekko.http.caching.scaladsl.Cache[
K, pekko.http.scaladsl.server.RouteResult]] =
CacheJavaMapping.cacheMapping[K, RouteResult, K, pekko.http.scaladsl.server.RouteResult]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private final class HttpsProxyGraphStage(
s"parseResult should be MessageEnd but was $parseResult")
parser.onPull() match {
// NeedMoreData is what we emit in overridden `parseMessage` in case input.size == offset
case NeedMoreData =>
case NeedMoreData =>
case RemainingBytes(bytes) =>
push(sslOut, bytes) // parser already read more than expected, forward that data directly
pushed = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ private[client] object NewHostConnectionPool {
val newRequest =
request.entity match {
case _: HttpEntity.Strict => request
case e =>
case e =>
val (newEntity, entityComplete) = HttpEntity.captureTermination(request.entity)
entityComplete.onComplete(safely {
case Success(_) => withSlot(_.onRequestEntityCompleted())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ private[http2] object FrameLogger {

def entryForFrame(frameEvent: FrameEvent): LogEntry =
frameEvent match {
case PingFrame(false, data) => LogEntry(0, "PING", hex(data))
case PingFrame(true, data) => LogEntry(0, "PONG", hex(data))
case PingFrame(false, data) => LogEntry(0, "PING", hex(data))
case PingFrame(true, data) => LogEntry(0, "PONG", hex(data))
case HeadersFrame(streamId, endStream, endHeaders, payload, prio) =>
val prioInfo = if (prio.isDefined) display(entryForFrame(prio.get)) + " " else ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private[http2] abstract class Http2Demux(http2Settings: Http2CommonSettings,
case WindowUpdateFrame(streamId, increment)
if streamId == 0 /* else fall through to StreamFrameEvent */ =>
multiplexer.updateConnectionLevelWindow(increment)
case p: PriorityFrame => multiplexer.updatePriority(p)
case p: PriorityFrame => multiplexer.updatePriority(p)
case s: StreamFrameEvent =>
if (!terminating)
handleStreamEvent(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ private[http2] trait Http2StreamHandling extends GraphStageLogic with LogHelper
}

debug(
s"Incoming side of stream [$streamId] changed state: ${oldState.stateName} -> ${newState.stateName} after handling [$event${if (eventArg ne null) s"($eventArg)" else ""}]")
s"Incoming side of stream [$streamId] changed state: ${oldState.stateName} -> ${newState.stateName} after handling [$event${if (eventArg ne null)
s"($eventArg)"
else ""}]")

stateMachineRunning = false
if (deferredStreamToEnqueue != -1) {
Expand Down Expand Up @@ -821,8 +823,8 @@ private[http2] trait Http2StreamHandling extends GraphStageLogic with LogHelper
// external callbacks, need to make sure that potential stream state changing events are run through the state machine
override def onPush(): Unit = {
inlet.grab() match {
case newData: ByteString => buffer ++= newData
case HttpEntity.Chunk(newData, _) => buffer ++= newData
case newData: ByteString => buffer ++= newData
case HttpEntity.Chunk(newData, _) => buffer ++= newData
case HttpEntity.LastChunk(_, headers) =>
if (headers.nonEmpty && !trailer.isEmpty)
log.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private[http] final class BodyPartParser(
@tailrec def loop(): Unit =
trampoline match {
case null =>
case f =>
case f =>
trampoline = null
f()
loop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ private[engine] final class HttpHeaderParser private (
@tailrec private def scanHeaderNameAndReturnIndexOfColon(input: ByteString, start: Int, limit: Int)(ix: Int): Int =
if (ix < limit)
(byteChar(input, ix), settings.illegalResponseHeaderNameProcessingMode) match {
case (':', _) => ix
case (c, _) if tchar(c) => scanHeaderNameAndReturnIndexOfColon(input, start, limit)(ix + 1)
case (':', _) => ix
case (c, _) if tchar(c) => scanHeaderNameAndReturnIndexOfColon(input, start, limit)(ix + 1)
case (c, IllegalResponseHeaderNameProcessingMode.Error) =>
fail(s"Illegal character '${escape(c)}' in header name")
case (c, IllegalResponseHeaderNameProcessingMode.Warn) =>
Expand All @@ -206,7 +206,9 @@ private[engine] final class HttpHeaderParser private (
try {
insert(input, header)(cursor, endIx, nodeIx, colonIx = 0)
values(branch.valueIx) = branch.withValueCountIncreased
} catch { case OutOfTrieSpaceException => /* if we cannot insert then we simply don't */ }
} catch {
case OutOfTrieSpaceException => /* if we cannot insert then we simply don't */
}
resultHeader = header
endIx
}
Expand All @@ -215,15 +217,15 @@ private[engine] final class HttpHeaderParser private (
if (char == node) // fast match, descend
parseHeaderValue(input, valueStart, branch)(cursor + 1, nodeIx + 1)
else node >>> 8 match {
case 0 => parseAndInsertHeader()
case 0 => parseAndInsertHeader()
case msb => node & 0xFF match {
case 0 => // leaf node
resultHeader = values(msb - 1).asInstanceOf[HttpHeader]
cursor
case nodeChar => // branching node
val signum = math.signum(char - nodeChar)
branchData(rowIx(msb) + 1 + signum) match {
case 0 => parseAndInsertHeader() // header doesn't exist yet
case 0 => parseAndInsertHeader() // header doesn't exist yet
case subNodeIx => // descend into branch and advance on char matches (otherwise descend but don't advance)
parseHeaderValue(input, valueStart, branch)(cursor + 1 - math.abs(signum), subNodeIx)
}
Expand Down Expand Up @@ -353,7 +355,7 @@ private[engine] final class HttpHeaderParser private (
val node = nodes(nodeIx)
val char = escape((node & 0xFF).toChar)
node >>> 8 match {
case 0 => recurseAndPrefixLines(nodeIx + 1, " ", char + "-", " ")
case 0 => recurseAndPrefixLines(nodeIx + 1, " ", char + "-", " ")
case msb => node & 0xFF match {
case 0 => values(msb - 1) match {
case ValueBranch(_, valueParser, branchRootNodeIx, _) =>
Expand Down Expand Up @@ -392,7 +394,7 @@ private[engine] final class HttpHeaderParser private (
def build(nodeIx: Int = 0): Map[String, Int] = {
val node = nodes(nodeIx)
node >>> 8 match {
case 0 => build(nodeIx + 1)
case 0 => build(nodeIx + 1)
case msb if (node & 0xFF) == 0 =>
values(msb - 1) match {
case ValueBranch(_, parser, _, count) => Map(parser.headerName -> count)
Expand Down Expand Up @@ -568,7 +570,7 @@ private[http] object HttpHeaderParser {
settings.illegalResponseHeaderValueProcessingMode)()
val trimmedHeaderValue = headerValue.trim
val header = parser(trimmedHeaderValue) match {
case HeaderParser.Success(h) => h
case HeaderParser.Success(h) => h
case HeaderParser.Failure(error) =>
onIllegalHeader(error.withSummaryPrepended(s"Illegal '$headerName' header").withErrorHeaderName(headerName))
RawHeader(headerName, trimmedHeaderValue)
Expand Down Expand Up @@ -599,7 +601,7 @@ private[http] object HttpHeaderParser {
def appended2(c: Int) = if ((c >> 16) != 0) appended(c.toChar).append((c >> 16).toChar) else appended(c.toChar)
if (ix < limit)
byteChar(input, ix) match {
case '\t' => scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 1)
case '\t' => scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 1)
case '\r' if byteAt(input, ix + 1) == LF_BYTE =>
if (WSP(byteChar(input, ix + 2))) scanHeaderValue(hhp, input, start, limit, log, mode)(appended(' '), ix + 3)
else (if (sb != null) sb.toString else asciiString(input, start, ix), ix + 2)
Expand Down
Loading