View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
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.RequestEntity;
21  import org.apache.commons.httpclient.methods.TraceMethod;
22  
23  import com.eviware.soapui.impl.rest.RestRequestInterface;
24  import com.eviware.soapui.impl.wsdl.submit.transports.http.ExtendedHttpMethod;
25  import com.eviware.soapui.impl.wsdl.submit.transports.http.HttpMethodSupport;
26  import com.eviware.soapui.impl.wsdl.submit.transports.http.SSLInfo;
27  
28  /***
29   * Extended PostMethod that supports limiting of response size and detailed
30   * timestamps
31   * 
32   * @author Ole.Matzura
33   */
34  
35  public final class ExtendedTraceMethod extends TraceMethod implements ExtendedHttpMethod
36  {
37  	private HttpMethodSupport httpMethodSupport;
38  	private IAfterRequestInjection afterRequestInjection;
39  
40  	public ExtendedTraceMethod()
41  	{
42  		super( null );
43  		httpMethodSupport = new HttpMethodSupport( this );
44  	}
45  
46  	public String getDumpFile()
47  	{
48  		return httpMethodSupport.getDumpFile();
49  	}
50  
51  	public void setDumpFile( String dumpFile )
52  	{
53  		httpMethodSupport.setDumpFile( dumpFile );
54  	}
55  
56  	public boolean hasResponse()
57  	{
58  		return httpMethodSupport.hasResponse();
59  	}
60  
61  	protected void readResponse( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
62  	{
63  		super.readResponse( arg0, arg1 );
64  		httpMethodSupport.afterReadResponse( arg0, arg1 );
65  	}
66  
67  	@Override
68  	public String getResponseCharSet()
69  	{
70  		return httpMethodSupport.getResponseCharset();
71  	}
72  
73  	public long getMaxSize()
74  	{
75  		return httpMethodSupport.getMaxSize();
76  	}
77  
78  	public void setMaxSize( long maxSize )
79  	{
80  		httpMethodSupport.setMaxSize( maxSize );
81  	}
82  
83  	public long getResponseReadTime()
84  	{
85  		return httpMethodSupport.getResponseReadTime();
86  	}
87  
88  	protected void writeRequest( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
89  	{
90  		super.writeRequest( arg0, arg1 );
91  		httpMethodSupport.afterWriteRequest( arg0, arg1 );
92  		if( afterRequestInjection != null )
93  			afterRequestInjection.executeAfterRequest();
94  	}
95  
96  	public void initStartTime()
97  	{
98  		httpMethodSupport.initStartTime();
99  	}
100 
101 	public long getTimeTaken()
102 	{
103 		return httpMethodSupport.getTimeTaken();
104 	}
105 
106 	public long getStartTime()
107 	{
108 		return httpMethodSupport.getStartTime();
109 	}
110 
111 	public byte[] getResponseBody() throws IOException
112 	{
113 		return httpMethodSupport.getResponseBody();
114 	}
115 
116 	public SSLInfo getSSLInfo()
117 	{
118 		return httpMethodSupport.getSSLInfo();
119 	}
120 
121 	public String getResponseContentType()
122 	{
123 		return httpMethodSupport.getResponseContentType();
124 	}
125 
126 	public RestRequestInterface.RequestMethod getMethod()
127 	{
128 		return RestRequestInterface.RequestMethod.TRACE;
129 	}
130 
131 	public void setAfterRequestInjection( IAfterRequestInjection injection )
132 	{
133 		afterRequestInjection = injection;
134 	}
135 
136 	public RequestEntity getRequestEntity()
137 	{
138 		return null;
139 	}
140 	
141 	public Throwable getFailureCause()
142 	{
143 		return httpMethodSupport.getFailureCause();
144 	}
145 
146 	public boolean isFailed()
147 	{
148 		return httpMethodSupport.isFailed();
149 	}
150 
151 	public void setFailed( Throwable t )
152 	{
153 		httpMethodSupport.setFailed( t );
154 	}
155 }