You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/05/03 13:09:43 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpClient.java
olegk 2003/05/03 04:09:42
Modified: httpclient/src/java/org/apache/commons/httpclient
HttpClient.java
Log:
Adds an override of HttpClient.executeMethod that lets the
caller specify an HttpState object. This allows advanced clients that
need to mess around with the http state (e.g. different cookies for
different threads) to use HttpClient rather than manipulating
connections and connection managers directly
Contributed by Laura Werner <la...@lwerner.org>
Committed by Oleg Kalnichevski
Revision Changes Path
1.74 +37 -11 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
Index: HttpClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- HttpClient.java 10 Apr 2003 21:01:00 -0000 1.73
+++ HttpClient.java 3 May 2003 11:09:42 -0000 1.74
@@ -498,16 +498,41 @@
method.getHostConfiguration() != null
? method.getHostConfiguration()
: getHostConfiguration(),
- method
+ method,
+ null
);
}
+
+ /**
+ * Executes the given method.
+ *
+ * @param hostConfiguration The configuration to use.
+ * @param method the {@link HttpMethod} to execute.
+ * @return the method's response code
+ *
+ * @throws IOException if an I/O error occurs
+ * @throws HttpException if a protocol exception occurs
+ * @since 2.0
+ */
+ public int executeMethod(HostConfiguration hostConfiguration, HttpMethod method)
+ throws IOException, HttpException {
+
+ LOG.trace("enter HttpClient.executeMethod(HostConfiguration,HttpMethod)");
+
+ return executeMethod(hostConfiguration, method, null);
+ }
+
+
/**
* Executes the given method.
*
* @param hostConfiguration The configuration to use.
* @param method the {@link HttpMethod} to execute.
+ * @param state the {@link HttpState} to use when executing the method.
+ * If <code>null</code>, the state returned by {@link #getState} will be used instead.
+ *
* @return the method's response code
*
* @throws IOException if an I/O error occurs
@@ -515,20 +540,19 @@
* @since 2.0
*/
public int executeMethod(HostConfiguration hostConfiguration,
- HttpMethod method)
+ HttpMethod method, HttpState state)
throws IOException, HttpException {
- LOG.trace("enter HttpClient.executeMethod(HostConfiguration,HttpMethod)");
+ LOG.trace("enter HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)");
- if (null == method) {
- throw new NullPointerException("HttpMethod parameter");
+ if (method == null) {
+ throw new IllegalArgumentException("HttpMethod parameter may not be null");
}
int soTimeout = 0;
boolean strictMode = false;
int connectionTimeout = 0;
long httpConnectionTimeout = 0;
- HttpState state = null;
HostConfiguration defaultHostConfiguration = null;
/* access all synchronized data in a single block, this will keeps us
@@ -540,7 +564,9 @@
strictMode = this.strictMode;
connectionTimeout = this.connectionTimeout;
httpConnectionTimeout = this.httpConnectionTimeout;
- state = getState();
+ if (state == null) {
+ state = getState();
+ }
defaultHostConfiguration = getHostConfiguration();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org