On Mon, 2008-11-17 at 16:39 -0800, Adrian Blakey wrote:
> My server does not seem to want to close the connection. When I run
> this in NetBeans the read method blocks and I get a notification that
> says - "Step is blocked by suspended thread "Reference Handler"
>
> The content length header is not returned.
>
> How do I tell it to close?
>
> My client looks a bit like this:
>
> HttpGet get = new HttpGet(uri);
> int status = 0;
> HttpEntity entity = null;
> try {
> HttpResponse response = client.execute(get);
> entity = response.getEntity();
> long len = entity.getContentLength();
> StatusLine statusLine = response.getStatusLine();
> status = statusLine.getStatusCode();
> BufferedReader reader = new BufferedReader(
> new InputStreamReader(entity.getContent()));
> try {
> String thisLine = null;
> while ((thisLine = reader.readLine()) != null)
> { <<<<=======
HttpUriRequest#abort() is your friend.
Oleg
> log.debug(thisLine);
> }
> } catch (IOException ex) {
> log.error("unable to get list, status " + status + "
> " + ex);
> } catch (RuntimeException ex) {
> get.abort();
> throw ex;
> } finally {
> reader.close();
> }
> } catch (IOException ioe) {
> log.error("unable to get trace, status " + status + " " +
> ioe);
> throw new RuntimeException(ioe);
> } finally {
> if (entity != null) {
> try {
> entity.consumeContent();
> } catch (IOException ex) {
> // nop
> }
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]