View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 com.eviware.soapui.impl.support.AbstractHttpRequest;
16  import com.eviware.soapui.impl.wsdl.submit.transports.http.ExtendedHttpMethod;
17  import com.eviware.soapui.impl.wsdl.submit.transports.http.HttpMethodSupport;
18  import com.eviware.soapui.impl.wsdl.submit.transports.http.SSLInfo;
19  import org.apache.commons.httpclient.HttpConnection;
20  import org.apache.commons.httpclient.HttpException;
21  import org.apache.commons.httpclient.HttpState;
22  import org.apache.commons.httpclient.methods.PostMethod;
23  
24  import java.io.IOException;
25  
26  /***
27   * Extended PostMethod that supports limiting of response size and detailed
28   * timestamps
29   * 
30   * @author Ole.Matzura
31   */
32  
33  public final class ExtendedPostMethod extends PostMethod implements ExtendedHttpMethod
34  {
35  	private HttpMethodSupport httpMethodSupport;
36  
37  	public ExtendedPostMethod()
38  	{
39  		httpMethodSupport = new HttpMethodSupport( this );
40  	}
41  	
42  	public String getDumpFile()
43  	{
44  		return httpMethodSupport.getDumpFile();
45  	}
46  
47  	public void setDumpFile(String dumpFile)
48  	{
49  		httpMethodSupport.setDumpFile(dumpFile);
50  	}
51  
52  	protected void readResponse(HttpState arg0, HttpConnection arg1)
53  			throws IOException, HttpException
54  	{
55  		super.readResponse(arg0, arg1);
56  		httpMethodSupport.afterReadResponse(arg0, arg1);
57  	}
58  
59  	public long getMaxSize()
60  	{
61  		return httpMethodSupport.getMaxSize();
62  	}
63  
64  	public void setMaxSize(long maxSize)
65  	{
66  		httpMethodSupport.setMaxSize( maxSize );
67  	}
68  
69  	public long getResponseReadTime()
70  	{
71  		return httpMethodSupport.getResponseReadTime();
72  	}
73  
74  	protected void writeRequest(HttpState arg0, HttpConnection arg1)
75  			throws IOException, HttpException
76  	{
77  		super.writeRequest(arg0, arg1);
78  		httpMethodSupport.afterWriteRequest(arg0, arg1);
79  	}
80  
81  	public void initStartTime()
82  	{
83  		httpMethodSupport.initStartTime();
84  	}
85  
86  	public long getTimeTaken()
87  	{
88  		return httpMethodSupport.getTimeTaken();
89  	}
90  
91  	public long getStartTime()
92  	{
93  		return httpMethodSupport.getStartTime();
94  	}
95  
96  	public byte[] getResponseBody() throws IOException
97  	{
98  		return httpMethodSupport.getResponseBody();
99  	}
100 
101 	public SSLInfo getSSLInfo()
102 	{
103 		return httpMethodSupport.getSSLInfo();
104 	}
105 
106 	public String getResponseContentType()
107 	{
108 		return httpMethodSupport.getResponseContentType();
109 	}
110 
111    public AbstractHttpRequest.RequestMethod getMethod() {
112       return AbstractHttpRequest.RequestMethod.POST;
113    }
114 
115 }