Skip to content
Permalink
Browse files
[NO ISSUE][OTH] Add util method to get request http scheme
- user model changes: no
- storage format changes: no
- interface changes: no

Details:

- Add util method to get request http scheme.
- Allow exceptions to be thrown from servletNotFound.

Change-Id: I85e88223a0ec3291be4423cf5dc146d7d7d09903
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/11224
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
  • Loading branch information
mhubail committed Apr 29, 2021
1 parent 61aad74 commit 82f19315dde3cf25191314ea558ba0e7d3c474d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
@@ -18,8 +18,6 @@
*/
package org.apache.hyracks.http.server;

import static org.apache.hyracks.http.server.utils.HttpUtil.X_FORWARDED_PROTO;

import java.io.IOException;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
@@ -143,9 +141,7 @@ protected void respond(ChannelHandlerContext ctx, HttpRequest request, HttpRespo
private void submit(ChannelHandlerContext ctx, IServlet servlet, FullHttpRequest request) throws IOException {
IServletRequest servletRequest;
try {
HttpScheme scheme =
server.getScheme() == HttpScheme.HTTPS || "https".equals(request.headers().get(X_FORWARDED_PROTO))
? HttpScheme.HTTPS : HttpScheme.HTTP;
HttpScheme scheme = HttpUtil.getScheme(server, request);
servletRequest = createServletRequest(ctx, request, scheme);
} catch (IllegalArgumentException e) {
LOGGER.log(Level.WARN, "Failure Decoding Request", e);
@@ -166,7 +162,7 @@ private void submit(IServlet servlet) throws IOException {
}
}

protected void handleServletNotFound(ChannelHandlerContext ctx, FullHttpRequest request) {
protected void handleServletNotFound(ChannelHandlerContext ctx, FullHttpRequest request) throws IOException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No servlet for " + request.uri());
}
@@ -43,6 +43,7 @@
import org.apache.hyracks.http.api.IServletResponse;
import org.apache.hyracks.http.server.BaseRequest;
import org.apache.hyracks.http.server.FormUrlEncodedRequest;
import org.apache.hyracks.http.server.HttpServer;
import org.apache.hyracks.util.ThrowingConsumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -230,6 +231,11 @@ public void close() throws IOException {
}
}

public static HttpScheme getScheme(HttpServer server, FullHttpRequest request) {
return server.getScheme() == HttpScheme.HTTPS || "https".equals(request.headers().get(X_FORWARDED_PROTO))
? HttpScheme.HTTPS : HttpScheme.HTTP;
}

public static class ContentType {
public static final String ADM = "adm";
public static final String JSON = "json";

0 comments on commit 82f1931

Please sign in to comment.