hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Lee" <crazy...@crazybob.org>
Subject Can we make it easier to release resources?
Date Fri, 20 Jun 2008 18:50:55 GMT
Right now, we have to do something like this:

HttpResponse r = client.execute(...)
try {
  ...
} finally {
  HttpEntity e = r.getEntity();
  if (e != null) {
    // Soon to be renamed finish()
    e.consumeContent();
  }
}

It might be nice if we could do something like this:

HttpResponse r = client.execute(...)
try {
  ...
} finally {
   response.finish();
}

Or even something like this:

public interface ResponseHandler<T> {
  T handle(HttpResponse response) throws IOException;
}

String result = client.execute(myHandler);

Then you could have a few reusable response handlers, like a JSON handler,
and XML handler, etc.

Bob

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message