parse

fun parse(value: String, nowEpochMillis: Long): Result<Duration>(source)

Reads value against the local clock: a date's delay is the date minus nowEpochMillis.

Return

the delay, or an IllegalArgumentException whose constant message says whether the value was empty, malformed or out of range; it never echoes the value.

Parameters

value

the header value.

nowEpochMillis

the local clock, in epoch milliseconds.


fun parse(value: String, nowEpochMillis: Long, serverDateEpochMillis: Long): Result<Duration>(source)

Reads value against the server's own clock: a date's delay is the date minus serverDateEpochMillis (the response's Date), so a skewed local clock cancels out of a pair of server readings.

Return

the delay, or an IllegalArgumentException for text that is not a Retry-After value.

Parameters

value

the header value.

nowEpochMillis

the local clock, in epoch milliseconds; not read by this overload (the server's Date replaces it), accepted so both overloads take the same leading arguments.

serverDateEpochMillis

the response's Date, in epoch milliseconds.