mirror of https://github.com/apache/nifi.git
NIFI-4413: - Using the incoming request to determine the appropriate scheme for the data reference URI. Necessary for cases where the NiFi instance is behind a proxy running a different scheme.
This closes #2179. Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
parent
b7b6d9082c
commit
d47bbd12ce
|
@ -84,6 +84,11 @@
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-server</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -18,15 +18,6 @@ package org.apache.nifi.web;
|
||||||
|
|
||||||
import com.ibm.icu.text.CharsetDetector;
|
import com.ibm.icu.text.CharsetDetector;
|
||||||
import com.ibm.icu.text.CharsetMatch;
|
import com.ibm.icu.text.CharsetMatch;
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URI;
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -40,6 +31,17 @@ import org.apache.tika.mime.MediaType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller servlet for viewing content. This is responsible for generating
|
* Controller servlet for viewing content. This is responsible for generating
|
||||||
* the markup for the header and footer of the page. Included in that is the
|
* the markup for the header and footer of the page. Included in that is the
|
||||||
|
@ -299,7 +301,12 @@ public class ContentViewerController extends HttpServlet {
|
||||||
final String ref = request.getParameter("ref");
|
final String ref = request.getParameter("ref");
|
||||||
final String clientId = request.getParameter("clientId");
|
final String clientId = request.getParameter("clientId");
|
||||||
|
|
||||||
final URI refUri = URI.create(ref);
|
// base the data ref on the request parameter but ensure the scheme is based off the incoming request...
|
||||||
|
// this is necessary for scenario's where the NiFi instance is behind a proxy running a different scheme
|
||||||
|
final URI refUri = UriBuilder.fromUri(ref)
|
||||||
|
.scheme(request.getScheme())
|
||||||
|
.build();
|
||||||
|
|
||||||
final String query = refUri.getQuery();
|
final String query = refUri.getQuery();
|
||||||
|
|
||||||
String rawClusterNodeId = null;
|
String rawClusterNodeId = null;
|
||||||
|
@ -317,7 +324,7 @@ public class ContentViewerController extends HttpServlet {
|
||||||
return new ContentRequestContext() {
|
return new ContentRequestContext() {
|
||||||
@Override
|
@Override
|
||||||
public String getDataUri() {
|
public String getDataUri() {
|
||||||
return ref;
|
return refUri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue