Issue: SPR-12196
master
Juergen Hoeller 10 years ago
parent 26a93b6a33
commit f394c8aa2a
  1. 8
      spring-web/src/main/java/org/springframework/http/client/AbstractClientHttpRequest.java
  2. 33
      spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java
  3. 4
      spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,7 +23,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.Assert;
/**
* Abstract base for {@link ClientHttpRequest} that makes sure that headers and body are not written multiple times.
* Abstract base for {@link ClientHttpRequest} that makes sure that headers
* and body are not written multiple times.
*
* @author Arjen Poutsma
* @since 3.0
@ -55,8 +56,7 @@ public abstract class AbstractClientHttpRequest implements ClientHttpRequest {
}
/**
* Asserts that this request has not been {@linkplain #execute() executed} yet.
*
* Assert that this request has not been {@linkplain #execute() executed} yet.
* @throws IllegalStateException if this request has been executed
*/
protected void assertNotExecuted() {

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
/**
* {@link ClientHttpRequestFactory} implementation that uses standard J2SE facilities.
* {@link ClientHttpRequestFactory} implementation that uses standard JDK facilities.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
@ -36,8 +36,7 @@ import org.springframework.util.Assert;
* @see java.net.HttpURLConnection
* @see HttpComponentsClientHttpRequestFactory
*/
public class SimpleClientHttpRequestFactory
implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory {
public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory {
private static final int DEFAULT_CHUNK_SIZE = 4096;
@ -111,14 +110,12 @@ public class SimpleClientHttpRequestFactory
}
/**
* Set if the underlying URLConnection can be set to 'output streaming' mode. When
* output streaming is enabled, authentication and redirection cannot be handled
* automatically. If output streaming is disabled the
* {@link HttpURLConnection#setFixedLengthStreamingMode(int)
* setFixedLengthStreamingMode} and
* {@link HttpURLConnection#setChunkedStreamingMode(int) setChunkedStreamingMode}
* methods of the underlying connection will never be called.
* <p>Default is {@code true}.
* Set if the underlying URLConnection can be set to 'output streaming' mode.
* Default is {@code true}.
* <p>When output streaming is enabled, authentication and redirection cannot be handled automatically.
* If output streaming is disabled, the {@link HttpURLConnection#setFixedLengthStreamingMode} and
* {@link HttpURLConnection#setChunkedStreamingMode} methods of the underlying connection will never
* be called.
* @param outputStreaming if output streaming is enabled
*/
public void setOutputStreaming(boolean outputStreaming) {
@ -126,15 +123,15 @@ public class SimpleClientHttpRequestFactory
}
/**
* Sets the task executor for this request factory. Setting this property is required
* for {@linkplain #createAsyncRequest(URI, HttpMethod) creating asynchronous
* request}.
* Set the task executor for this request factory. Setting this property is required
* for {@linkplain #createAsyncRequest(URI, HttpMethod) creating asynchronous requests}.
* @param taskExecutor the task executor
*/
public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
@Override
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
HttpURLConnection connection = openConnection(uri.toURL(), this.proxy);
@ -153,10 +150,8 @@ public class SimpleClientHttpRequestFactory
* is required before calling this method.
*/
@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod)
throws IOException {
Assert.state(this.taskExecutor != null, "Asynchronous execution requires an " +
"AsyncTaskExecutor to be set");
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
Assert.state(this.taskExecutor != null, "Asynchronous execution requires an AsyncTaskExecutor to be set");
HttpURLConnection connection = openConnection(uri.toURL(), this.proxy);
prepareConnection(connection, httpMethod.name());
if (this.bufferRequestBody) {

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.StringUtils;
/**
* {@link ClientHttpResponse} implementation that uses standard J2SE facilities.
* {@link ClientHttpResponse} implementation that uses standard JDK facilities.
* Obtained via {@link SimpleBufferingClientHttpRequest#execute()} and
* {@link SimpleStreamingClientHttpRequest#execute()}.
*

Loading…
Cancel
Save