-
Notifications
You must be signed in to change notification settings - Fork 44
GET Method
Ankush Mishra edited this page Nov 9, 2018
·
1 revision
The HttpGetMethod
is an extension of the HttpGet
class in HttpClient 4.x, to allow calendar specific settings to be applied.
Specifically this allows you to return the response body returned as a Calendar
object. This class should thus, only be used if the response body is calendar, otherwise HttpGet
can be used for normal purposes.
String uri = "http://example.com/path/to/calendar.ics";
CalDAV4JMethodFactory factory = new CalDAV4JMethodFactory();
HttpGetMethod method = factory.createGetMethod(uri);
// Execute the method.
HttpResponse response = client.execute(method);
// Retrieve the Calendar from the response.
Calendar calendar = method.getResponseBodyAsCalendar(response);
String uri = "http://example.com/path/to/calendar.ics";
CalendarBuilder builder = new CalendarBuilder();
HttpGetMethod method = new HttpGetMethod(uri, builder);
// Execute the method.
HttpResponse response = client.execute(method);
// Retrieve the Calendar from the response.
Calendar calendar = method.getResponseBodyAsCalendar(response);