knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [15/37] knox git commit: KNOX-1068 - Add support for HTTP Head request
Date Thu, 26 Oct 2017 14:22:51 GMT
KNOX-1068 - Add support for HTTP Head request


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/10b3473a
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/10b3473a
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/10b3473a

Branch: refs/heads/KNOX-1049
Commit: 10b3473ae0ab88645322ef4798f9eb696cb59b93
Parents: a841e26
Author: Sandeep More <more@apache.org>
Authored: Tue Sep 26 14:24:30 2017 -0400
Committer: Sandeep More <more@apache.org>
Committed: Tue Sep 26 14:24:30 2017 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/dispatch/AbstractGatewayDispatch.java    | 8 ++++++++
 .../org/apache/hadoop/gateway/dispatch/DefaultDispatch.java | 9 +++++++++
 .../java/org/apache/hadoop/gateway/dispatch/Dispatch.java   | 6 ++++++
 .../hadoop/gateway/dispatch/GatewayDispatchFilter.java      | 8 ++++++++
 4 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/10b3473a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
index 70a6996..16a09fc 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/AbstractGatewayDispatch.java
@@ -115,6 +115,14 @@ public abstract class AbstractGatewayDispatch implements Dispatch {
       throws IOException, URISyntaxException {
     response.sendError( HttpServletResponse.SC_METHOD_NOT_ALLOWED );
   }
+
+  /**
+   * @sine 0.14.0
+   */
+  public void doHead( URI url, HttpServletRequest request, HttpServletResponse response )
+      throws IOException, URISyntaxException {
+    response.sendError( HttpServletResponse.SC_METHOD_NOT_ALLOWED );
+  }
   
   public void copyRequestHeaderFields(HttpUriRequest outboundRequest,
       HttpServletRequest inboundRequest) {

http://git-wip-us.apache.org/repos/asf/knox/blob/10b3473a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
index 4b9e95d..d3633a9 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/DefaultDispatch.java
@@ -36,6 +36,7 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
 import org.apache.http.client.methods.HttpOptions;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
@@ -312,6 +313,14 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
       executeRequest(method, request, response);
    }
 
+  @Override
+  public void doHead(URI url, HttpServletRequest request, HttpServletResponse response)
+      throws IOException, URISyntaxException {
+    final HttpHead method = new HttpHead(url);
+    copyRequestHeaderFields(method, request);
+    executeRequest(method, request, response);
+  }
+
   public Set<String> getOutboundResponseExcludeHeaders() {
     return outboundResponseExcludeHeaders;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/10b3473a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/Dispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/Dispatch.java b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/Dispatch.java
index de08117..506e22b 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/Dispatch.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/Dispatch.java
@@ -53,4 +53,10 @@ public interface Dispatch {
   void doOptions( URI url, HttpServletRequest request, HttpServletResponse response )
       throws IOException, ServletException, URISyntaxException;
 
+  /**
+   * @since 0.14.0
+   */
+  void doHead( URI url, HttpServletRequest request, HttpServletResponse response )
+      throws IOException, ServletException, URISyntaxException;
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/10b3473a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
index acfa92e..4799ec2 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/dispatch/GatewayDispatchFilter.java
@@ -54,6 +54,7 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
     map.put("PUT", new PutAdapter());
     map.put("DELETE", new DeleteAdapter());
     map.put("OPTIONS", new OptionsAdapter());
+    map.put("HEAD", new HeadAdapter());
     return Collections.unmodifiableMap(map);
   }
 
@@ -152,6 +153,13 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
     }
   }
 
+  private static class HeadAdapter implements Adapter {
+    public void doMethod(Dispatch dispatch, HttpServletRequest request, HttpServletResponse
response)
+        throws IOException, ServletException, URISyntaxException {
+      dispatch.doHead( dispatch.getDispatchUrl(request), request, response);
+    }
+  }
+
   private <T> T newInstanceFromName(String dispatchImpl) throws ServletException {
     try {
       Class<T> clazz = loadClass(dispatchImpl);


Mime
View raw message