Skip to content
Permalink
Browse files
Request factory classes to re-use Method#normalizedValueOf
  • Loading branch information
ok2c committed Mar 11, 2021
1 parent b6b89a7 commit d41d67fa942818cadac5fe5c984eeb70d1f0b574
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 38 deletions.
@@ -28,12 +28,10 @@
package org.apache.hc.client5.http.async.methods;

import java.net.URI;
import java.util.Locale;

import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.util.Args;

/**
* Common HTTP methods using {@link BasicHttpRequest} as a HTTP request message representation.
@@ -42,12 +40,6 @@
*/
public final class BasicHttpRequests {

// TODO Next version of HttpCore:
// Method.normalizedValueOf(method)
private static Method normalizedValueOf(final String method) {
return Method.valueOf(Args.notNull(method, "method").toUpperCase(Locale.ROOT));
}

/**
* Creates a new BasicHttpRequest for the given {@code method} and {@code String} URI.
*
@@ -56,9 +48,7 @@ private static Method normalizedValueOf(final String method) {
* @return A new BasicHttpRequest.
*/
public static BasicHttpRequest create(final String method, final String uri) {
// TODO Next version of HttpCore:
// return create(Method.normalizedValueOf(method), uri);
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

/**
@@ -69,9 +59,7 @@ public static BasicHttpRequest create(final String method, final String uri) {
* @return A new BasicHttpRequest.
*/
public static BasicHttpRequest create(final String method, final URI uri) {
// TODO Next version of HttpCore:
// return create(Method.normalizedValueOf(method), uri);
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

public static BasicHttpRequest delete(final String uri) {
@@ -28,11 +28,9 @@
package org.apache.hc.client5.http.async.methods;

import java.net.URI;
import java.util.Locale;

import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.util.Args;

/**
* Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation.
@@ -41,12 +39,6 @@
*/
public final class SimpleHttpRequests {

// TODO Next version of HttpCore:
// Method.normalizedValueOf(method)
private static Method normalizedValueOf(final String method) {
return Method.valueOf(Args.notNull(method, "method").toUpperCase(Locale.ROOT));
}

/**
* Creates a new BasicHttpRequest for the given {@code method} and {@code String} URI.
*
@@ -55,9 +47,7 @@ private static Method normalizedValueOf(final String method) {
* @return A new BasicHttpRequest.
*/
public static SimpleHttpRequest create(final String method, final String uri) {
// TODO Next version of HttpCore:
// return create(Method.normalizedValueOf(method), uri);
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

/**
@@ -68,9 +58,7 @@ public static SimpleHttpRequest create(final String method, final String uri) {
* @return A new BasicHttpRequest.
*/
public static SimpleHttpRequest create(final String method, final URI uri) {
// TODO Next version of HttpCore:
// return create(Method.normalizedValueOf(method), uri);
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

public static SimpleHttpRequest delete(final String uri) {
@@ -28,12 +28,10 @@
package org.apache.hc.client5.http.classic.methods;

import java.net.URI;
import java.util.Locale;

import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.util.Args;


/**
* Common HTTP methods using {@link HttpUriRequest} as a HTTP request message representation.
* <p>
@@ -44,12 +42,6 @@
*/
public final class ClassicHttpRequests {

private static Method normalizedValueOf(final String method) {
// TODO Next version of HttpCore:
// Method.normalizedValueOf(method)
return Method.valueOf(Args.notNull(method, "method").toUpperCase(Locale.ROOT));
}

/**
* Creates a new HttpUriRequest for the given {@code Method} and {@code String} URI.
*
@@ -101,7 +93,7 @@ public static HttpUriRequest create(final Method method, final URI uri) {
* @return A new HttpUriRequest.
*/
public static HttpUriRequest create(final String method, final String uri) {
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

/**
@@ -114,7 +106,7 @@ public static HttpUriRequest create(final String method, final String uri) {
* @return A new HttpUriRequest.
*/
public static HttpUriRequest create(final String method, final URI uri) {
return create(normalizedValueOf(method), uri);
return create(Method.normalizedValueOf(method), uri);
}

public static HttpUriRequest delete(final String uri) {

0 comments on commit d41d67f

Please sign in to comment.