Conditional GET in Restlet

November 5, 2007

This is an extension to an old-but-useful post on implementing conditional GET in Java. I’ve been using the Restlet library more and more, and had some problems working out how to implement conditional GET, so here’s a brief recipe.


import org.restlet.Client;
import org.restlet.data.Conditions;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;

...
Request get = new Request(Method.GET, "http://www.example.com/");
get.getConditions().setModifiedSince(lastModified);
Client client = new Client(Protocol.HTTP);
Response res = client.handle(get);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: