Skip to content

Commit

Permalink
reproduce EOFException error with new failing tests in ConnectInterce…
Browse files Browse the repository at this point in the history
…ptorTest
  • Loading branch information
erawhctim committed Oct 31, 2023
1 parent 97e7548 commit ce9d23e
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,34 @@ class ConnectInterceptorTest {
assertThat(decompressed.readUtf8()).isEqualTo("message")
}

@Test
fun compressedEmptyRequestMessage() {
val config = ProtocolClientConfig(
host = "https://connectrpc.com",
serializationStrategy = serializationStrategy,
requestCompression = RequestCompression(1, GzipCompressionPool),
compressionPools = listOf(GzipCompressionPool),
)
val connectInterceptor = ConnectInterceptor(config)
val unaryFunction = connectInterceptor.unaryFunction()

val request = unaryFunction.requestFunction(
HTTPRequest(
url = URL(config.host),
contentType = "content_type",
headers = emptyMap(),
message = "".commonAsUtf8ToByteArray(),
methodSpec = MethodSpec(
path = "",
requestClass = Any::class,
responseClass = Any::class,
),
),
)
val decompressed = GzipCompressionPool.decompress(Buffer().write(request.message!!))
assertThat(decompressed.readUtf8()).isEqualTo("")
}

@Test
fun uncompressedResponseMessage() {
val config = ProtocolClientConfig(
Expand Down Expand Up @@ -214,6 +242,28 @@ class ConnectInterceptorTest {
assertThat(response.message.readUtf8()).isEqualTo("message")
}

@Test
fun compressedEmptyResponseMessage() {
val config = ProtocolClientConfig(
host = "https://connectrpc.com",
serializationStrategy = serializationStrategy,
compressionPools = listOf(GzipCompressionPool),
)
val connectInterceptor = ConnectInterceptor(config)
val unaryFunction = connectInterceptor.unaryFunction()

val response = unaryFunction.responseFunction(
HTTPResponse(
code = Code.OK,
headers = mapOf(CONTENT_ENCODING to listOf(GzipCompressionPool.name())),
message = Buffer(),
trailers = emptyMap(),
tracingInfo = null,
),
)
assertThat(response.message.readUtf8()).isEqualTo("")
}

@Test
fun responseError() {
val config = ProtocolClientConfig(
Expand Down

0 comments on commit ce9d23e

Please sign in to comment.