`Status.UNKNOWN_HOST` and `Status.CONNECTION_REFUS...
# http4k
m
Status.UNKNOWN_HOST
and
Status.CONNECTION_REFUSED
are equal, is that intentional? Try this:
Copy code
fun main() {
    println(Status.SERVICE_UNAVAILABLE == Status.UNKNOWN_HOST)
    println(Status.UNKNOWN_HOST == Status.CONNECTION_REFUSED)
}
Gives:
Copy code
false
true
The reason is that they have the same
code
(503) and both are
clientGenerated
.
d
it is intentional. The idea was to encapsulate and communicate different reasons for client side 503s (which are our invention to avoid throwing exceptions out of our HTTP clients)
m
But what if you want to distinguish between unknown host and connection refused?
It makes sense that they both have code 503, but maybe the
equals
method should be able to distinguish between them somehow anyway?
d
our thinking was that as far as the client is concerned, there is no difference. Both could be transient
of course, you can create a custom equality method to check the message as well if you need it.
m
BTW, I just discovered that the
hashCode
method does not take
clientGenerated
into account (as
equals
does), making it inconsistent with
equals
.
d
ah - that is a problem.
m
(FWIW, I reported an issue about this: https://github.com/http4k/http4k/issues/845)
(Not about the
hashCode
thing.)
d
ah - we're going to close that as won't fix BTW 🙂
but good to have it documented
m
Yes, it would be good to have your motivation in the GitHub issue as well (more permanent than here on Slack).
Reported issue about the
hashCode
thing also: https://github.com/http4k/http4k/issues/846
j
I think perhaps separating unknown host and connection refused is worthwhile. Unknown host means that dns name is not defined - maybe its wrong! or resolver not working (which can happen sure), but connection refused means that the server was contacted and responded with a specific icmp message, that server was not listening on that port at that second, or maybe listen queue exceeded, So you almost got there! They seem different.