1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 }