Skip to content

Commit

Permalink
spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
jhump committed May 15, 2024
1 parent 6fabe84 commit 112e545
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ internal class ConnectInterceptor(
} else {
message = responseBody
val isValidContentType =
(serializationStrategy.serializationName() == "json" && contentTypeIsJSON(contentType))
|| contentType == "application/" + serializationStrategy.serializationName()
(serializationStrategy.serializationName() == "json" && contentTypeIsJSON(contentType)) ||
contentType == "application/" + serializationStrategy.serializationName()
if (isValidContentType) {
exception = null
} else {
Expand Down Expand Up @@ -184,11 +184,13 @@ internal class ConnectInterceptor(
// this an internal error. Otherwise, we infer a code from the HTTP status,
// which means a code of UNKNOWN since HTTP status is 200.
val code = if (contentType.startsWith("application/connect+")) Code.INTERNAL_ERROR else Code.UNKNOWN
StreamResult.Complete(ConnectException(
code = code,
message = "unexpected content-type: $contentType",
metadata = responseHeaders,
))
StreamResult.Complete(
ConnectException(
code = code,
message = "unexpected content-type: $contentType",
metadata = responseHeaders,
),
)
} else {
responseCompressionPool =
clientConfig.compressionPool(responseHeaders[CONNECT_STREAMING_CONTENT_ENCODING]?.first())
Expand Down Expand Up @@ -357,4 +359,4 @@ fun Headers.toLowercase(): Headers {
}.aggregate { _: String, accumulator: List<String>?, element: Map.Entry<String, List<String>>, _: Boolean ->
accumulator?.plus(element.value) ?: element.value
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal class GRPCInterceptor(
cause = ConnectException(
code = Code.UNIMPLEMENTED,
message = "unary stream has no messages",
metadata = headers.plus(trailers)
metadata = headers.plus(trailers),
),
)
}
Expand All @@ -123,7 +123,7 @@ internal class GRPCInterceptor(
cause = ConnectException(
code = Code.UNIMPLEMENTED,
message = "unary stream has multiple messages",
metadata = headers.plus(trailers)
metadata = headers.plus(trailers),
),
)
}
Expand Down Expand Up @@ -217,11 +217,11 @@ internal class GRPCInterceptor(
}
}

internal fun contentTypeIsGRPC(contentType: String) : Boolean {
internal fun contentTypeIsGRPC(contentType: String): Boolean {
return contentType == "application/grpc" || contentType.startsWith("application/grpc+")
}

internal fun contentTypeIsExpectedGRPC(contentType: String, expectCodec: String) : Boolean {
return (expectCodec == "proto" && contentType == "application/grpc" )
|| contentType == "application/grpc+$expectCodec"
}
internal fun contentTypeIsExpectedGRPC(contentType: String, expectCodec: String): Boolean {
return (expectCodec == "proto" && contentType == "application/grpc") ||
contentType == "application/grpc+$expectCodec"
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ internal class GRPCWebInterceptor(
}
}

internal fun contentTypeIsGRPCWeb(contentType: String) : Boolean {
internal fun contentTypeIsGRPCWeb(contentType: String): Boolean {
return contentType == "application/grpc-web" || contentType.startsWith("application/grpc-web+")
}

internal fun contentTypeIsExpectedGRPCWeb(contentType: String, expectCodec: String) : Boolean {
return (expectCodec == "proto" && contentType == "application/grpc-web" )
|| contentType == "application/grpc-web+$expectCodec"
}
internal fun contentTypeIsExpectedGRPCWeb(contentType: String, expectCodec: String): Boolean {
return (expectCodec == "proto" && contentType == "application/grpc-web") ||
contentType == "application/grpc-web+$expectCodec"
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ class InterceptorChainTest {

@Test
fun lifo_stream_result() {
val streamResult = streamingChain.streamResultFunction(StreamResult.Headers(
mapOf(CONTENT_TYPE to listOf("application/connect+encoding_type")),
)) as StreamResult.Headers
val streamResult = streamingChain.streamResultFunction(
StreamResult.Headers(
mapOf(CONTENT_TYPE to listOf("application/connect+encoding_type")),
),
) as StreamResult.Headers
assertThat(streamResult.headers["id"]).containsExactly("4", "3", "2", "1")
}

Expand Down

0 comments on commit 112e545

Please sign in to comment.