View Javadoc

1   /*
2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/java/org/apache/commons/httpclient/methods/RequestEntity.java $
3    * $Revision: 1425331 $
4    * $Date: 2012-12-22 19:29:41 +0100 (Sat, 22 Dec 2012) $
5    *
6    * ====================================================================
7    *
8    *  Licensed to the Apache Software Foundation (ASF) under one or more
9    *  contributor license agreements.  See the NOTICE file distributed with
10   *  this work for additional information regarding copyright ownership.
11   *  The ASF licenses this file to You under the Apache License, Version 2.0
12   *  (the "License"); you may not use this file except in compliance with
13   *  the License.  You may obtain a copy of the License at
14   *
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   *
17   *  Unless required by applicable law or agreed to in writing, software
18   *  distributed under the License is distributed on an "AS IS" BASIS,
19   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   *  See the License for the specific language governing permissions and
21   *  limitations under the License.
22   * ====================================================================
23   *
24   * This software consists of voluntary contributions made by many
25   * individuals on behalf of the Apache Software Foundation.  For more
26   * information on the Apache Software Foundation, please see
27   * <http://www.apache.org/>.
28   *
29   */
30  
31  package org.apache.commons.httpclient.methods;
32  
33  import java.io.IOException;
34  import java.io.OutputStream;
35  
36  /***
37   * @since 3.0
38   */
39  public interface RequestEntity {
40  
41      /***
42       * Tests if {@link #writeRequest(OutputStream)} can be called more than once.
43       * 
44       * @return <tt>true</tt> if the entity can be written to {@link OutputStream} more than once, 
45       * <tt>false</tt> otherwise.
46       */
47      boolean isRepeatable();
48  
49      /***
50       * Writes the request entity to the given stream.
51       * @param out
52       * @throws IOException
53       */
54      void writeRequest(OutputStream out) throws IOException;
55      
56      /***
57       * Gets the request entity's length. This method should return a non-negative value if the content 
58       * length is known or a negative value if it is not. In the latter case the
59       * {@link org.apache.commons.httpclient.methods.EntityEnclosingMethod} will use chunk encoding to
60       * transmit the request entity.
61       *  
62       * @return a non-negative value when content length is known or a negative value when content length 
63       * is not known  
64       */
65      long getContentLength();
66      
67      /***
68       * Gets the entity's content type.  This content type will be used as the value for the
69       * "Content-Type" header.
70       * @return the entity's content type
71       * @see org.apache.commons.httpclient.HttpMethod#setRequestHeader(String, String)
72       */
73      String getContentType();
74      
75  }