View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.OptionsMethod;
21  import org.apache.commons.httpclient.methods.RequestEntity;
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 ExtendedOptionsMethod extends OptionsMethod implements ExtendedHttpMethod
36  {
37  	private HttpMethodSupport httpMethodSupport;
38  	private IAfterRequestInjection afterRequestInjection;
39  
40  	public ExtendedOptionsMethod()
41  	{
42  		httpMethodSupport = new HttpMethodSupport( this );
43  	}
44  
45  	public String getDumpFile()
46  	{
47  		return httpMethodSupport.getDumpFile();
48  	}
49  
50  	public void setDumpFile( String dumpFile )
51  	{
52  		httpMethodSupport.setDumpFile( dumpFile );
53  	}
54  
55  	public boolean hasResponse()
56  	{
57  		return httpMethodSupport.hasResponse();
58  	}
59  
60  	protected void readResponse( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
61  	{
62  		super.readResponse( arg0, arg1 );
63  		httpMethodSupport.afterReadResponse( arg0, arg1 );
64  	}
65  
66  	@Override
67  	public String getResponseCharSet()
68  	{
69  		return httpMethodSupport.getResponseCharset();
70  	}
71  
72  	public long getMaxSize()
73  	{
74  		return httpMethodSupport.getMaxSize();
75  	}
76  
77  	public void setMaxSize( long maxSize )
78  	{
79  		httpMethodSupport.setMaxSize( maxSize );
80  	}
81  
82  	public long getResponseReadTime()
83  	{
84  		return httpMethodSupport.getResponseReadTime();
85  	}
86  
87  	protected void writeRequest( HttpState arg0, HttpConnection arg1 ) throws IOException, HttpException
88  	{
89  		super.writeRequest( arg0, arg1 );
90  		httpMethodSupport.afterWriteRequest( arg0, arg1 );
91  		if( afterRequestInjection != null )
92  			afterRequestInjection.executeAfterRequest();
93  	}
94  
95  	public void initStartTime()
96  	{
97  		httpMethodSupport.initStartTime();
98  	}
99  
100 	public long getTimeTaken()
101 	{
102 		return httpMethodSupport.getTimeTaken();
103 	}
104 
105 	public long getStartTime()
106 	{
107 		return httpMethodSupport.getStartTime();
108 	}
109 
110 	public byte[] getResponseBody() throws IOException
111 	{
112 		return httpMethodSupport.getResponseBody();
113 	}
114 
115 	public SSLInfo getSSLInfo()
116 	{
117 		return httpMethodSupport.getSSLInfo();
118 	}
119 
120 	public String getResponseContentType()
121 	{
122 		return httpMethodSupport.getResponseContentType();
123 	}
124 
125 	public RestRequestInterface.RequestMethod getMethod()
126 	{
127 		return RestRequestInterface.RequestMethod.OPTIONS;
128 	}
129 
130 	public void setAfterRequestInjection( IAfterRequestInjection injection )
131 	{
132 		afterRequestInjection = injection;
133 	}
134 
135 	public RequestEntity getRequestEntity()
136 	{
137 		return null;
138 	}
139 	
140 	public Throwable getFailureCause()
141 	{
142 		return httpMethodSupport.getFailureCause();
143 	}
144 
145 	public boolean isFailed()
146 	{
147 		return httpMethodSupport.isFailed();
148 	}
149 
150 	public void setFailed( Throwable t )
151 	{
152 		httpMethodSupport.setFailed( t );
153 	}
154 }