Skip to content

Commit

Permalink
Merge pull request #49 from expath/feature/apache-http5
Browse files Browse the repository at this point in the history
Update to Apache Http Components 5
  • Loading branch information
adamretter authored Jun 18, 2024
2 parents 21b7511 + 3af9838 commit da87776
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 163 deletions.
8 changes: 4 additions & 4 deletions http-client-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
<artifactId>tools-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

package org.expath.httpclient;

import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.NameValuePair;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.message.MessageSupport;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -50,7 +51,7 @@ public ContentType(final String type, final String charset, final String boundar
if (header == null || !"Content-Type".equalsIgnoreCase(header.getName())) {
throw new HttpClientException(HttpClientError.HC001, "Header is not content type");
}
final HeaderElement[] headerElements = header.getElements();
final HeaderElement[] headerElements = MessageSupport.parse(header);
if (headerElements.length > 1) {
throw new HttpClientException(HttpClientError.HC001, "Multiple Content-Type headers");
}
Expand All @@ -71,7 +72,7 @@ public ContentType(final String type, final String charset, final String boundar
if (header == null || !"Content-Type".equalsIgnoreCase(header.getName())) {
throw new HttpClientException(HttpClientError.HC001, "Header is not content type");
}
final HeaderElement[] headerElements = header.getElements();
final HeaderElement[] headerElements = MessageSupport.parse(header);
if (headerElements.length > 1) {
throw new HttpClientException(HttpClientError.HC001, "Multiple Content-Type headers");
}
Expand All @@ -90,7 +91,7 @@ public ContentType(final String type, final String charset, final String boundar
throw new HttpClientException(HttpClientError.HC001, "Header is not Content-Type");
}

final HeaderElement[] headerElements = header.getElements();
final HeaderElement[] headerElements = MessageSupport.parse(header);
if (headerElements.length > 1) {
throw new HttpClientException(HttpClientError.HC001, "Multiple Content-Type headers");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.message.BasicHeader;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.message.BasicHeader;

/**
* TODO: Doc...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.expath.httpclient.impl;

import java.net.URI;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;

/**
* Implements any HTTP extension method, without any entity content.
Expand All @@ -23,35 +23,22 @@
* @author Florent Georges
*/
public class AnyEmptyMethod
extends HttpRequestBase
extends BasicClassicHttpRequest
{
public AnyEmptyMethod(String method)
{
super();
METHOD_NAME = method;
super(method, (String) null);
}

public AnyEmptyMethod(String method, URI uri)
{
super();
METHOD_NAME = method;
setURI(uri);
super(method, uri);
}

public AnyEmptyMethod(String method, String uri)
{
super();
METHOD_NAME = method;
setURI(URI.create(uri));
super(method, URI.create(uri));
}

@Override
public String getMethod()
{
return METHOD_NAME;
}

public String METHOD_NAME;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package org.expath.httpclient.impl;

import java.net.URI;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;

/**
* Implements any HTTP extension method, without any entity content.
Expand All @@ -23,35 +23,22 @@
* @author Florent Georges
*/
public class AnyEntityMethod
extends HttpEntityEnclosingRequestBase
extends BasicClassicHttpRequest
{
public AnyEntityMethod(String method)
{
super();
METHOD_NAME = method;
super(method, (String) null);
}

public AnyEntityMethod(String method, URI uri)
{
super();
METHOD_NAME = method;
setURI(uri);
super(method, uri);
}

public AnyEntityMethod(String method, String uri)
{
super();
METHOD_NAME = method;
setURI(URI.create(uri));
super(method, URI.create(uri));
}

@Override
public String getMethod()
{
return METHOD_NAME;
}

public String METHOD_NAME;
}


Expand Down
Loading

0 comments on commit da87776

Please sign in to comment.