You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Adrian Blakey <ad...@gmail.com> on 2008/11/18 19:26:18 UTC

Read block when running under TomCat

I am reading a byte stream from an IIS 4.0 server, mime type  
application/octet-stream. When run as a standalone java app. it works  
fine, as do two other simpler GETs from the server. When I run it as a  
servlet under TomCat 6.0.18 the read blocks. It's jdk 1.5.0_16 on a  
Mac - if that makes any difference.

I have tried setting headers and timeout - any other ideas about what  
is going on here?

         HttpGet get = new HttpGet(uri);
         HttpParams params = get.getParams();
         params.setParameter(HttpConnectionParams.CONNECTION_TIMEOUT,  
3000);
         get.setParams(params);
         BasicHeader header = new BasicHeader("Connection", "close");
         get.addHeader(header);
         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)  
{ <<==== Blocks
                     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