"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

RequestBuilder.java  (httpcomponents-client-4.5.6-src):RequestBuilder.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 75 skipping to change at line 75
* </p> * </p>
* *
* @since 4.3 * @since 4.3
*/ */
public class RequestBuilder { public class RequestBuilder {
private String method; private String method;
private Charset charset; private Charset charset;
private ProtocolVersion version; private ProtocolVersion version;
private URI uri; private URI uri;
private HeaderGroup headergroup; private HeaderGroup headerGroup;
private HttpEntity entity; private HttpEntity entity;
private List<NameValuePair> parameters; private List<NameValuePair> parameters;
private RequestConfig config; private RequestConfig config;
RequestBuilder(final String method) { RequestBuilder(final String method) {
super(); super();
this.charset = Consts.UTF_8; this.charset = Consts.UTF_8;
this.method = method; this.method = method;
} }
skipping to change at line 266 skipping to change at line 266
return new RequestBuilder().doCopy(request); return new RequestBuilder().doCopy(request);
} }
private RequestBuilder doCopy(final HttpRequest request) { private RequestBuilder doCopy(final HttpRequest request) {
if (request == null) { if (request == null) {
return this; return this;
} }
method = request.getRequestLine().getMethod(); method = request.getRequestLine().getMethod();
version = request.getRequestLine().getProtocolVersion(); version = request.getRequestLine().getProtocolVersion();
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
headergroup.clear(); headerGroup.clear();
headergroup.setHeaders(request.getAllHeaders()); headerGroup.setHeaders(request.getAllHeaders());
parameters = null; parameters = null;
entity = null; entity = null;
if (request instanceof HttpEntityEnclosingRequest) { if (request instanceof HttpEntityEnclosingRequest) {
final HttpEntity originalEntity = ((HttpEntityEnclosingRequest) requ est).getEntity(); final HttpEntity originalEntity = ((HttpEntityEnclosingRequest) requ est).getEntity();
final ContentType contentType = ContentType.get(originalEntity); final ContentType contentType = ContentType.get(originalEntity);
if (contentType != null && if (contentType != null &&
contentType.getMimeType().equals(ContentType.APPLICATION_FOR M_URLENCODED.getMimeType())) { contentType.getMimeType().equals(ContentType.APPLICATION_FOR M_URLENCODED.getMimeType())) {
try { try {
skipping to change at line 350 skipping to change at line 350
this.uri = uri; this.uri = uri;
return this; return this;
} }
public RequestBuilder setUri(final String uri) { public RequestBuilder setUri(final String uri) {
this.uri = uri != null ? URI.create(uri) : null; this.uri = uri != null ? URI.create(uri) : null;
return this; return this;
} }
public Header getFirstHeader(final String name) { public Header getFirstHeader(final String name) {
return headergroup != null ? headergroup.getFirstHeader(name) : null; return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
} }
public Header getLastHeader(final String name) { public Header getLastHeader(final String name) {
return headergroup != null ? headergroup.getLastHeader(name) : null; return headerGroup != null ? headerGroup.getLastHeader(name) : null;
} }
public Header[] getHeaders(final String name) { public Header[] getHeaders(final String name) {
return headergroup != null ? headergroup.getHeaders(name) : null; return headerGroup != null ? headerGroup.getHeaders(name) : null;
} }
public RequestBuilder addHeader(final Header header) { public RequestBuilder addHeader(final Header header) {
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
headergroup.addHeader(header); headerGroup.addHeader(header);
return this; return this;
} }
public RequestBuilder addHeader(final String name, final String value) { public RequestBuilder addHeader(final String name, final String value) {
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
this.headergroup.addHeader(new BasicHeader(name, value)); this.headerGroup.addHeader(new BasicHeader(name, value));
return this; return this;
} }
public RequestBuilder removeHeader(final Header header) { public RequestBuilder removeHeader(final Header header) {
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
headergroup.removeHeader(header); headerGroup.removeHeader(header);
return this; return this;
} }
public RequestBuilder removeHeaders(final String name) { public RequestBuilder removeHeaders(final String name) {
if (name == null || headergroup == null) { if (name == null || headerGroup == null) {
return this; return this;
} }
for (final HeaderIterator i = headergroup.iterator(); i.hasNext(); ) { for (final HeaderIterator i = headerGroup.iterator(); i.hasNext(); ) {
final Header header = i.nextHeader(); final Header header = i.nextHeader();
if (name.equalsIgnoreCase(header.getName())) { if (name.equalsIgnoreCase(header.getName())) {
i.remove(); i.remove();
} }
} }
return this; return this;
} }
public RequestBuilder setHeader(final Header header) { public RequestBuilder setHeader(final Header header) {
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
this.headergroup.updateHeader(header); this.headerGroup.updateHeader(header);
return this; return this;
} }
public RequestBuilder setHeader(final String name, final String value) { public RequestBuilder setHeader(final String name, final String value) {
if (headergroup == null) { if (headerGroup == null) {
headergroup = new HeaderGroup(); headerGroup = new HeaderGroup();
} }
this.headergroup.updateHeader(new BasicHeader(name, value)); this.headerGroup.updateHeader(new BasicHeader(name, value));
return this; return this;
} }
public HttpEntity getEntity() { public HttpEntity getEntity() {
return entity; return entity;
} }
public RequestBuilder setEntity(final HttpEntity entity) { public RequestBuilder setEntity(final HttpEntity entity) {
this.entity = entity; this.entity = entity;
return this; return this;
skipping to change at line 485 skipping to change at line 485
} }
if (entityCopy == null) { if (entityCopy == null) {
result = new InternalRequest(method); result = new InternalRequest(method);
} else { } else {
final InternalEntityEclosingRequest request = new InternalEntityEclo singRequest(method); final InternalEntityEclosingRequest request = new InternalEntityEclo singRequest(method);
request.setEntity(entityCopy); request.setEntity(entityCopy);
result = request; result = request;
} }
result.setProtocolVersion(this.version); result.setProtocolVersion(this.version);
result.setURI(uriNotNull); result.setURI(uriNotNull);
if (this.headergroup != null) { if (this.headerGroup != null) {
result.setHeaders(this.headergroup.getAllHeaders()); result.setHeaders(this.headerGroup.getAllHeaders());
} }
result.setConfig(this.config); result.setConfig(this.config);
return result; return result;
} }
static class InternalRequest extends HttpRequestBase { static class InternalRequest extends HttpRequestBase {
private final String method; private final String method;
InternalRequest(final String method) { InternalRequest(final String method) {
skipping to change at line 524 skipping to change at line 524
this.method = method; this.method = method;
} }
@Override @Override
public String getMethod() { public String getMethod() {
return this.method; return this.method;
} }
} }
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("RequestBuilder [method=");
builder.append(method);
builder.append(", charset=");
builder.append(charset);
builder.append(", version=");
builder.append(version);
builder.append(", uri=");
builder.append(uri);
builder.append(", headerGroup=");
builder.append(headerGroup);
builder.append(", entity=");
builder.append(entity);
builder.append(", parameters=");
builder.append(parameters);
builder.append(", config=");
builder.append(config);
builder.append("]");
return builder.toString();
}
} }
 End of changes. 20 change blocks. 
27 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)