Package com.browserup.bup.filters
Class HttpsAwareFiltersAdapter
- java.lang.Object
-
- org.littleshoot.proxy.HttpFiltersAdapter
-
- com.browserup.bup.filters.HttpsAwareFiltersAdapter
-
- All Implemented Interfaces:
org.littleshoot.proxy.HttpFilters
- Direct Known Subclasses:
AutoBasicAuthFilter,BlacklistFilter,HarCaptureFilter,HttpConnectHarCaptureFilter,RequestFilterAdapter,ResponseFilterAdapter,RewriteUrlFilter,WhitelistFilter
public class HttpsAwareFiltersAdapter extends org.littleshoot.proxy.HttpFiltersAdapterThe HttpsAwareFiltersAdapter exposes the original host and the "real" host (after filter modifications) to filters for HTTPS requets. HTTPS requests do not normally contain the host in the URI, and the Host header may be missing or spoofed. Note: ThegetHttpsRequestHostAndPort()andgetHttpsOriginalRequestHostAndPort()methods can only be called when the request is an HTTPS request. Otherwise they will throw an IllegalStateException.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHOST_ATTRIBUTE_NAMEstatic java.lang.StringIS_HTTPS_ATTRIBUTE_NAMEstatic java.lang.StringORIGINAL_HOST_ATTRIBUTE_NAME
-
Constructor Summary
Constructors Constructor Description HttpsAwareFiltersAdapter(io.netty.handler.codec.http.HttpRequest originalRequest, io.netty.channel.ChannelHandlerContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetFullUrl(io.netty.handler.codec.http.HttpRequest modifiedRequest)Returns the full, absolute URL of the specified request for both HTTP and HTTPS URLs.java.lang.StringgetHost(io.netty.handler.codec.http.HttpRequest modifiedRequest)Returns the hostname (but not the port) the specified request for both HTTP and HTTPS requests.java.lang.StringgetHostAndPort(io.netty.handler.codec.http.HttpRequest modifiedRequest)Returns the host and port of the specified request for both HTTP and HTTPS requests.java.lang.StringgetOriginalUrl()Returns the full, absolute URL of the original request from the client for both HTTP and HTTPS URLs.booleanisHttps()Returns true if this is an HTTPS request.-
Methods inherited from class org.littleshoot.proxy.HttpFiltersAdapter
clientToProxyRequest, proxyToClientResponse, proxyToServerConnectionFailed, proxyToServerConnectionQueued, proxyToServerConnectionSSLHandshakeStarted, proxyToServerConnectionStarted, proxyToServerConnectionSucceeded, proxyToServerRequest, proxyToServerRequestSending, proxyToServerRequestSent, proxyToServerResolutionFailed, proxyToServerResolutionStarted, proxyToServerResolutionSucceeded, serverToProxyResponse, serverToProxyResponseReceived, serverToProxyResponseReceiving, serverToProxyResponseTimedOut
-
-
-
-
Field Detail
-
IS_HTTPS_ATTRIBUTE_NAME
public static final java.lang.String IS_HTTPS_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
HOST_ATTRIBUTE_NAME
public static final java.lang.String HOST_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
ORIGINAL_HOST_ATTRIBUTE_NAME
public static final java.lang.String ORIGINAL_HOST_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
isHttps
public boolean isHttps()
Returns true if this is an HTTPS request.- Returns:
- true if https, false if http
-
getFullUrl
public java.lang.String getFullUrl(io.netty.handler.codec.http.HttpRequest modifiedRequest)
Returns the full, absolute URL of the specified request for both HTTP and HTTPS URLs. The request may reflect modifications from this or other filters. This filter instance must be currently handling the specified request; otherwise the results are undefined.- Parameters:
modifiedRequest- a possibly-modified version of the request currently being processed- Returns:
- the full URL of the request, including scheme, host, port, path, and query parameters
-
getOriginalUrl
public java.lang.String getOriginalUrl()
Returns the full, absolute URL of the original request from the client for both HTTP and HTTPS URLs. The URL will not reflect modifications from this or other filters.- Returns:
- the full URL of the original request, including scheme, host, port, path, and query parameters
-
getHost
public java.lang.String getHost(io.netty.handler.codec.http.HttpRequest modifiedRequest)
Returns the hostname (but not the port) the specified request for both HTTP and HTTPS requests. The request may reflect modifications from this or other filters. This filter instance must be currently handling the specified request; otherwise the results are undefined.- Parameters:
modifiedRequest- a possibly-modified version of the request currently being processed- Returns:
- hostname of the specified request, without the port
-
getHostAndPort
public java.lang.String getHostAndPort(io.netty.handler.codec.http.HttpRequest modifiedRequest)
Returns the host and port of the specified request for both HTTP and HTTPS requests. The request may reflect modifications from this or other filters. This filter instance must be currently handling the specified request; otherwise the results are undefined.- Parameters:
modifiedRequest- a possibly-modified version of the request currently being processed- Returns:
- host and port of the specified request
-
-