hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Blakey <adrianbla...@gmail.com>
Subject Telling the server to close its connection?
Date Tue, 18 Nov 2008 00:39:01 GMT
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)  
{ <<<<=======
                     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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message