1   /*
2    * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/SimpleHttpMethod.java,v 1.6.2.1 2004/02/22 18:21:16 olegk Exp $
3    * $Revision: 1.6.2.1 $
4    * $Date: 2004/02/22 18:21:16 $
5    * ====================================================================
6    *
7    *  Copyright 1999-2004 The Apache Software Foundation
8    *
9    *  Licensed under the Apache License, Version 2.0 (the "License");
10   *  you may not use this file except in compliance with the License.
11   *  You may obtain a copy of the License at
12   *
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   *
15   *  Unless required by applicable law or agreed to in writing, software
16   *  distributed under the License is distributed on an "AS IS" BASIS,
17   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   *  See the License for the specific language governing permissions and
19   *  limitations under the License.
20   * ====================================================================
21   *
22   * This software consists of voluntary contributions made by many
23   * individuals on behalf of the Apache Software Foundation.  For more
24   * information on the Apache Software Foundation, please see
25   * <http://www.apache.org/>.
26   *
27   * [Additional notices, if required by prior licensing conditions]
28   *
29   */
30  
31  
32  package org.apache.commons.httpclient;
33  
34  import org.apache.commons.logging.Log;
35  import org.apache.commons.logging.LogFactory;
36  
37  import java.io.IOException;
38  
39  
40  /*** 
41   * For test-nohost testing purposes only.
42   *
43   * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
44   */
45  class SimpleHttpMethod extends HttpMethodBase{
46  
47      static Log log = LogFactory.getLog("httpclient.test");
48      Header header = null;
49  
50  	SimpleHttpMethod(){
51  		super();
52  	}
53  
54  	SimpleHttpMethod(String path){
55  		super(path);
56  	}
57  
58  	SimpleHttpMethod(Header header){
59  		super();
60          this.header = header;
61  	}
62  
63  	public String getName() {
64  		return "Simple";
65  	}
66  
67      /***
68       * Makes sure any respose header that exists has been added to the response
69       * header group.
70       */
71      private void ensureResponseHeaderIsSet() {
72          if ( header != null ) {
73              super.getResponseHeaderGroup().addHeader(header);
74              header = null;
75          }
76      }
77  
78      /***
79       * @see HttpMethod#execute(HttpState, HttpConnection)
80       */
81      public int execute(HttpState state, HttpConnection connection)
82          throws HttpException, IOException {
83          return super.execute(state, connection);
84      }
85  
86      /***
87       * @see HttpMethod#getResponseHeader(String)
88       * @deprecated
89       */
90      public Header getResponseHeader(String headerName) {
91          ensureResponseHeaderIsSet();
92          return super.getResponseHeader(headerName);
93      }
94  
95      /***
96       * @see HttpMethod#getResponseHeaderGroup()
97       */
98      protected HeaderGroup getResponseHeaderGroup() {
99          ensureResponseHeaderIsSet();
100         return super.getResponseHeaderGroup();
101     }
102 
103     /***
104      * @see HttpMethod#getResponseHeaders()
105      */
106     public Header[] getResponseHeaders() {
107         ensureResponseHeaderIsSet();
108         return super.getResponseHeaders();
109     }
110     
111     
112     public String getTestRequestLine(HttpConnection connection) {
113         return HttpMethodBase.generateRequestLine(connection, 
114           this.getName(), this.getPath(), this.getQueryString(), "HTTP/1.1");
115     }
116 }