In short, it is handled by the driver internally.
There is no server support (which make sense given failure to connect would preclude the presence of a server) in the libpq implementation of this behavior - i.e., its not a protocol thing but a client implementation. The JDBC driver does not utilize libpq at all, it directly implements the PostgreSQL communication protocol.