1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.submit.transports.http.support.methods;
14
15 import java.io.IOException;
16
17 import org.apache.commons.httpclient.HttpConnection;
18 import org.apache.commons.httpclient.HttpException;
19 import org.apache.commons.httpclient.HttpState;
20 import org.apache.commons.httpclient.methods.PostMethod;
21
22 import com.eviware.soapui.impl.rest.RestRequestInterface;
23 import com.eviware.soapui.impl.wsdl.submit.transports.http.ExtendedHttpMethod;
24 import com.eviware.soapui.impl.wsdl.submit.transports.http.HttpMethodSupport;
25 import com.eviware.soapui.impl.wsdl.submit.transports.http.SSLInfo;
26
27 /***
28 * Extended PostMethod that supports limiting of response size and detailed
29 * timestamps
30 *
31 * @author Ole.Matzura
32 */
33
34 public final class ExtendedPostMethod extends PostMethod implements ExtendedHttpMethod
35 {
36 private HttpMethodSupport httpMethodSupport;
37 private IAfterRequestInjection afterRequestInjection;
38 private boolean followRedirects;
39
40 public ExtendedPostMethod()
41 {
42 httpMethodSupport = new HttpMethodSupport( this );
43 }
44
45 public ExtendedPostMethod( String url )
46 {
47 super( url );
48 httpMethodSupport = new HttpMethodSupport( this );
49 }
50
51 public String getDumpFile()
52 {
53 return httpMethodSupport.getDumpFile();
54 }
55
56 public void setDumpFile( String dumpFile )
57 {
58 httpMethodSupport.setDumpFile( dumpFile );
59 }
60
61 @Override
62 public boolean getFollowRedirects()
63 {
64 return followRedirects;
65 }
66
67 @Override
68 public void setFollowRedirects( boolean followRedirects )
69 {
70 this.followRedirects = followRedirects;
71 }
72
73 public boolean hasResponse()
74 {
75 return httpMethodSupport.hasResponse();
76 }
77
78 protected void readResponse( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
79 {
80 super.readResponse( arg0, arg1 );
81 httpMethodSupport.afterReadResponse( arg0, arg1 );
82 }
83
84 @Override
85 public String getResponseCharSet()
86 {
87 return httpMethodSupport.getResponseCharset();
88 }
89
90 public long getMaxSize()
91 {
92 return httpMethodSupport.getMaxSize();
93 }
94
95 public void setMaxSize( long maxSize )
96 {
97 httpMethodSupport.setMaxSize( maxSize );
98 }
99
100 public long getResponseReadTime()
101 {
102 return httpMethodSupport.getResponseReadTime();
103 }
104
105 protected void writeRequest( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
106 {
107 super.writeRequest( arg0, arg1 );
108 httpMethodSupport.afterWriteRequest( arg0, arg1 );
109 if( afterRequestInjection != null )
110 afterRequestInjection.executeAfterRequest();
111 }
112
113 public void initStartTime()
114 {
115 httpMethodSupport.initStartTime();
116 }
117
118 public long getTimeTaken()
119 {
120 return httpMethodSupport.getTimeTaken();
121 }
122
123 public long getStartTime()
124 {
125 return httpMethodSupport.getStartTime();
126 }
127
128 public byte[] getResponseBody() throws IOException
129 {
130 return httpMethodSupport.getResponseBody();
131 }
132
133 public SSLInfo getSSLInfo()
134 {
135 return httpMethodSupport.getSSLInfo();
136 }
137
138 public String getResponseContentType()
139 {
140 return httpMethodSupport.getResponseContentType();
141 }
142
143 public RestRequestInterface.RequestMethod getMethod()
144 {
145 return RestRequestInterface.RequestMethod.POST;
146 }
147
148 public void setAfterRequestInjection( IAfterRequestInjection injection )
149 {
150 afterRequestInjection = injection;
151 }
152
153 public Throwable getFailureCause()
154 {
155 return httpMethodSupport.getFailureCause();
156 }
157
158 public boolean isFailed()
159 {
160 return httpMethodSupport.isFailed();
161 }
162
163 public void setFailed( Throwable t )
164 {
165 httpMethodSupport.setFailed( t );
166 }
167 }