Skip to content
Ankush Mishra edited this page Nov 9, 2018 · 1 revision

GET Method

Overview

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.

Usage

With CalDAV4JMethodFactory:

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);

Without

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);
Clone this wiki locally