Arne said:
The API is simpler than (Http)URLConnection, so even if
you don't need all the features, then it can be beneficial
to use.
Personally I don't see much difference in complexity. The
advantage of HttpClient is the better support for Cookies
and the handling of HTTP-sessions. But if you just want to
perform a single HTTP-request (GET or POST) you more or less
end up with the same code.
The advantage of using HttpUrlConnection is that there are
a lot more examples covering topics like accessing HTTPS-
servers that use "untrusted" certficates or requiring a
client-certificate. As soon as you have this topic handling
XML-files that need to load DTDs/XSDs that way you have to
cope with HttpUrlConnection-APIs anyway, even when using
Apache-classes doing the XML-parsing.
The decistion pro HttpUrlConnection and contra HttpClient I
finally made more than five years ago. Things might have
changed for HttpClient since then (and most likely the API
to be used, requiring significant changes in the code), but
my code works (and is officially certified), so I most likely
will not change it.
Regards, Lothar
--
Lothar Kimmeringer E-Mail: (e-mail address removed)
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!