No need to use the type name of an input arg in the method name. (#208)
* No need to use the type name of an input arg in the method name. * Do not use input type names in method names.
This commit is contained in:
parent
4401991d93
commit
d1c4199db3
|
@ -15,6 +15,13 @@
|
|||
SimpleHttpRequests.create(String, String)
|
||||
Contributed by Gary Gregory <ggregory at apache.org>
|
||||
|
||||
* GitHub #208: Do not use input type names in method names:
|
||||
SimpleHttpRequest: Deprecate setBodyBytes(byte[], ContentType) in favor of setBody(byte[], ContentType)
|
||||
SimpleHttpRequest: Deprecate setBodyText(String, ContentType) in favor of setBody(String, ContentType)
|
||||
SimpleHttpResponse: Deprecate setBodyBytes(byte[], ContentType) in favor of setBody(byte[], ContentType)
|
||||
SimpleHttpResponse: Deprecate setBodyText(String, ContentType) in favor of setBody(String, ContentType)
|
||||
Contributed by Gary Gregory <ggregory at apache.org>
|
||||
|
||||
|
||||
Release 5.0-BETA7
|
||||
-----------------
|
||||
|
|
|
@ -76,7 +76,7 @@ class CachedHttpResponseGenerator {
|
|||
final ContentType contentType = h != null ? ContentType.parse(h.getValue()) : null;
|
||||
final byte[] content = resource.get();
|
||||
addMissingContentLengthHeader(response, content);
|
||||
response.setBodyBytes(content, contentType);
|
||||
response.setBody(content, contentType);
|
||||
}
|
||||
|
||||
final TimeValue age = this.validityStrategy.getCurrentAge(entry, now);
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class AbstractSimpleServerExchangeHandler extends AbstractServer
|
|||
final ContentType contentType) {
|
||||
final SimpleHttpRequest simpleRequest = SimpleHttpRequest.copy(request);
|
||||
if (body != null) {
|
||||
simpleRequest.setBodyBytes(body, contentType);
|
||||
simpleRequest.setBody(body, contentType);
|
||||
}
|
||||
return simpleRequest;
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T extends CloseableH
|
|||
context.setCredentialsProvider(credsProvider);
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
|
@ -276,7 +276,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T extends CloseableH
|
|||
context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
|
@ -303,7 +303,7 @@ public abstract class AbstractHttpAsyncClientAuthentication<T extends CloseableH
|
|||
context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
|
||||
|
||||
final SimpleHttpRequest put = SimpleHttpRequests.put(target, "/");
|
||||
put.setBodyText("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
put.setBody("Some important stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(put, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
return response;
|
||||
} else if (path.equals("/newlocation/")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
|
||||
|
@ -166,7 +166,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
return response;
|
||||
} else if (path.equals("/relativelocation/")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
|
||||
|
@ -191,7 +191,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
return response;
|
||||
} else if (path.equals("/test/relativelocation")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
|
||||
|
@ -468,7 +468,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
final HttpClientContext context = HttpClientContext.create();
|
||||
|
||||
final SimpleHttpRequest post = SimpleHttpRequests.post(target, "/oldlocation/");
|
||||
post.setBodyText("stuff", ContentType.TEXT_PLAIN);
|
||||
post.setBody("stuff", ContentType.TEXT_PLAIN);
|
||||
final Future<SimpleHttpResponse> future = httpclient.execute(post, context, null);
|
||||
final HttpResponse response = future.get();
|
||||
Assert.assertNotNull(response);
|
||||
|
@ -553,7 +553,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
return response;
|
||||
} else if (path.equals("/relativelocation/")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
|
||||
|
@ -734,7 +734,7 @@ public abstract class AbstractHttpAsyncRedirectsTest <T extends CloseableHttpAsy
|
|||
final String path = requestURI.getPath();
|
||||
if (path.equals("/rome")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_MOVED_TEMPORARILY);
|
||||
|
|
|
@ -152,7 +152,7 @@ public class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest<Clos
|
|||
return response;
|
||||
} else if (path.equals("/newlocation/")) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Successful redirect", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
} else {
|
||||
return new SimpleHttpResponse(HttpStatus.SC_NOT_FOUND);
|
||||
|
|
|
@ -121,7 +121,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
|
|||
final SimpleHttpRequest request,
|
||||
final HttpCoreContext context) throws HttpException {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Whatever", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Whatever", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
@ -246,7 +246,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
|
|||
final SimpleHttpRequest request,
|
||||
final HttpCoreContext context) throws HttpException {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK);
|
||||
response.setBodyText("Whatever", ContentType.TEXT_PLAIN);
|
||||
response.setBody("Whatever", ContentType.TEXT_PLAIN);
|
||||
return response;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -85,10 +85,26 @@ public final class SimpleHttpRequest extends ConfigurableHttpRequest {
|
|||
this.body = body;
|
||||
}
|
||||
|
||||
public void setBody(final byte[] bodyBytes, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyBytes, contentType);
|
||||
}
|
||||
|
||||
public void setBody(final String bodyText, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyText, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setBody(byte[], ContentType)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setBodyBytes(final byte[] bodyBytes, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyBytes, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setBody(String, ContentType)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setBodyText(final String bodyText, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyText, contentType);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
|
|||
public static SimpleHttpResponse create(final int code, final String content, final ContentType contentType) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(code);
|
||||
if (content != null) {
|
||||
response.setBodyText(content, contentType);
|
||||
response.setBody(content, contentType);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
|
|||
public static SimpleHttpResponse create(final int code, final byte[] content, final ContentType contentType) {
|
||||
final SimpleHttpResponse response = new SimpleHttpResponse(code);
|
||||
if (content != null) {
|
||||
response.setBodyBytes(content, contentType);
|
||||
response.setBody(content, contentType);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
@ -97,10 +97,26 @@ public final class SimpleHttpResponse extends BasicHttpResponse {
|
|||
this.body = body;
|
||||
}
|
||||
|
||||
public void setBody(final byte[] bodyBytes, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyBytes, contentType);
|
||||
}
|
||||
|
||||
public void setBody(final String bodyText, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyText, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setBody(byte[], ContentType)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setBodyBytes(final byte[] bodyBytes, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyBytes, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setBody(String, ContentType)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setBodyText(final String bodyText, final ContentType contentType) {
|
||||
this.body = SimpleBody.create(bodyText, contentType);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class SimpleResponseConsumer extends AbstractAsyncResponseConsumer<
|
|||
protected SimpleHttpResponse buildResult(final HttpResponse response, final byte[] entity, final ContentType contentType) {
|
||||
final SimpleHttpResponse simpleResponse = SimpleHttpResponse.copy(response);
|
||||
if (entity != null) {
|
||||
simpleResponse.setBodyBytes(entity, contentType);
|
||||
simpleResponse.setBody(entity, contentType);
|
||||
}
|
||||
return simpleResponse;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue