HttpURLConnection does only support things like GET, POST and HEAD - but no REPORT/PROPFIND. I'm going to implement a CalDAV-Client but without theese operations (if I want to use them I get a ProtocolException) I have to write/deliver a complete and huge HTTP library with auth and so on.
"Overkill".
How do I send requests with PROPFIND and REPORT?
I had similar problem on WebDav for PROPFIND method.
Solved the problem by implementing this solution: https://java.net/jira/browse/JERSEY-639
try {
httpURLConnection.setRequestMethod(method);
} catch (final ProtocolException pe) {
try {
final Class<?> httpURLConnectionClass = httpURLConnection
.getClass();
final Class<?> parentClass = httpURLConnectionClass
.getSuperclass();
final Field methodField;
// If the implementation class is an HTTPS URL Connection, we
// need to go up one level higher in the heirarchy to modify the
// 'method' field.
if (parentClass == HttpsURLConnection.class) {
methodField = parentClass.getSuperclass().getDeclaredField(
"method");
} else {
methodField = parentClass.getDeclaredField("method");
}
methodField.setAccessible(true);
methodField.set(httpURLConnection, method);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
You'd probably want to look for a WebDAV libary, not an HTTP library, for this one.
Maybe take a look at Apache Jackrabbit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With