View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.http;
8   
9   import org.mule.model.streaming.DelegatingInputStream;
10  
11  import java.io.IOException;
12  import java.io.InputStream;
13  
14  import org.apache.commons.httpclient.HttpMethod;
15  
16  public class ReleasingInputStream extends DelegatingInputStream
17  {
18      private final HttpMethod method;
19  
20      public ReleasingInputStream(InputStream is, HttpMethod method)
21      {
22          super(is);
23          
24          this.method = method;
25      }
26  
27      public void close() throws IOException 
28      {
29          super.close();
30          
31          if (method != null)
32          {
33              method.releaseConnection();
34          }
35      }
36  }
37