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
@@ -0,0 +1,3 @@
package io.icure.asyncjacksonhttpclient.exception

class TimeoutException(cause: Throwable) : Exception(cause)
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ interface WebClient {

@ExperimentalCoroutinesApi
interface Request {
/**
* @duration set a response timeout
* @throws io.icure.asyncjacksonhttpclient.exception.TimeoutException if the [timeoutDuration] is elapsed while
* receiving the response
*/
fun method(method: HttpMethod, timeoutDuration: Duration? = null): Request
fun basicAuth(username: String, password: String): Request {
return header(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package io.icure.asyncjacksonhttpclient.netty

import io.icure.asyncjacksonhttpclient.exception.TimeoutException
import io.icure.asyncjacksonhttpclient.net.web.HttpMethod
import io.icure.asyncjacksonhttpclient.net.web.Request
import io.icure.asyncjacksonhttpclient.net.web.Response
Expand Down Expand Up @@ -131,6 +132,8 @@ class NettyResponse(
}.doOnTerminate {
timingHandler?.let { it(System.currentTimeMillis() - start).contextWrite(ctx).subscribe() }
}.single()
}.onErrorMap(io.netty.handler.timeout.ReadTimeoutException::class.java) {
TimeoutException(it)
}
}

Expand Down Expand Up @@ -170,7 +173,9 @@ class NettyResponse(
})
}.doOnTerminate {
timingHandler?.let { it(System.currentTimeMillis() - start).contextWrite(ctx).subscribe() }
} }
} }.onErrorMap(io.netty.handler.timeout.ReadTimeoutException::class.java) {
TimeoutException(it)
}
}

override fun onStatus(status: Int, handler: (ResponseStatus) -> Mono<out Throwable>): Response {
Expand Down