Open grenik opened 4 years ago
Hi Nikolay, this seem reasonable to me. I iwll take a look - hopefully soon. I sadly don't have much time for Cups4j, and with Corona around things don't get better. I will try to look at this soon. Thanks for your message! Harald
I can't provide a fix for this library, but a potential solution for your use case, grenik: With Corona around I had time to reimplement a new IppClient from scratch in Kotlin that supports ipps
and also includes a CupsClient.
RFC says:
However, you use URLs, not URIs. Since
ipp://
is not a valid protocol for ajava.net.URL
class, you simply replaceipp
withhttp
. This is already error-prone since some printers URIs haveipps://
protocol and you fail to process them.To prove the issue, you can call
getDefaultPrinter()
on a cups client with127.0.0.1
as host and631
as port. You will get the following error:If you use
localhost
as the host, you won't get an error.In addition to that, I see that to compare two URLs you call
toString()
on them and compare the resulting strings which doesn't seem right. Maybe you are doing the comparison this way becauseequals
cannot be used onjava.net.URL
since it has some issues (tries to resolve the hostname to an IP address).Since URIs in IPP have the same meaning as
java.net.URI
in Java (they both conform to RFC2396), I suggest that you switch tojava.net.URI
. You won't have issues withipp(s)
protocol and could also useequals()
to compare them because it is not broken as injava.net.URL
.