Java Code Examples for net.lightbody.bmp.util.HttpUtil#getHostFromRequest()

The following examples show how to use net.lightbody.bmp.util.HttpUtil#getHostFromRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImpersonatingMitmManager.java    From CapturePacket with MIT License 5 votes vote down vote up
@Override
public SSLEngine clientSslEngineFor(HttpRequest httpRequest, SSLSession sslSession) {
    String requestedHostname = HttpUtil.getHostFromRequest(httpRequest);

    try {
        SslContext ctx = getHostnameImpersonatingSslContext(requestedHostname, sslSession);

        return ctx.newEngine(ByteBufAllocator.DEFAULT);
    } catch (RuntimeException e) {
        throw new MitmException("Error creating SSLEngine for connection to client to impersonate upstream host: " + requestedHostname, e);
    }
}
 
Example 2
Source File: HttpsAwareFiltersAdapter.java    From CapturePacket with MIT License 5 votes vote down vote up
/**
 * 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.
 *
 * @param modifiedRequest a possibly-modified version of the request currently being processed
 * @return hostname of the specified request, without the port
 */
public String getHost(HttpRequest modifiedRequest) {
    String serverHost;
    if (isHttps()) {
        HostAndPort hostAndPort = HostAndPort.fromString(getHttpsRequestHostAndPort());
        serverHost = hostAndPort.getHost();
    } else {
        serverHost = HttpUtil.getHostFromRequest(modifiedRequest);
    }
    return serverHost;
}
 
Example 3
Source File: ImpersonatingMitmManager.java    From Dream-Catcher with MIT License 5 votes vote down vote up
@Override
public SSLEngine clientSslEngineFor(HttpRequest httpRequest, SSLSession sslSession) {
    String requestedHostname = HttpUtil.getHostFromRequest(httpRequest);

    try {
        SslContext ctx = getHostnameImpersonatingSslContext(requestedHostname, sslSession);

        return ctx.newEngine(ByteBufAllocator.DEFAULT);
    } catch (RuntimeException e) {
        throw new MitmException("Error creating SSLEngine for connection to client to impersonate upstream host: " + requestedHostname, e);
    }
}
 
Example 4
Source File: HttpsAwareFiltersAdapter.java    From Dream-Catcher with MIT License 5 votes vote down vote up
/**
 * 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.
 *
 * @param modifiedRequest a possibly-modified version of the request currently being processed
 * @return hostname of the specified request, without the port
 */
public String getHost(HttpRequest modifiedRequest) {
    String serverHost;
    if (isHttps()) {
        HostAndPort hostAndPort = HostAndPort.fromString(getHttpsRequestHostAndPort());
        serverHost = hostAndPort.getHostText();
    } else {
        serverHost = HttpUtil.getHostFromRequest(modifiedRequest);
    }
    return serverHost;
}
 
Example 5
Source File: ImpersonatingMitmManager.java    From AndroidHttpCapture with MIT License 5 votes vote down vote up
@Override
public SSLEngine clientSslEngineFor(HttpRequest httpRequest, SSLSession sslSession) {
    String requestedHostname = HttpUtil.getHostFromRequest(httpRequest);

    try {
        SslContext ctx = getHostnameImpersonatingSslContext(requestedHostname, sslSession);

        return ctx.newEngine(ByteBufAllocator.DEFAULT);
    } catch (RuntimeException e) {
        throw new MitmException("Error creating SSLEngine for connection to client to impersonate upstream host: " + requestedHostname, e);
    }
}
 
Example 6
Source File: HttpsAwareFiltersAdapter.java    From AndroidHttpCapture with MIT License 5 votes vote down vote up
/**
 * 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.
 *
 * @param modifiedRequest a possibly-modified version of the request currently being processed
 * @return hostname of the specified request, without the port
 */
public String getHost(HttpRequest modifiedRequest) {
    String serverHost;
    if (isHttps()) {
        HostAndPort hostAndPort = HostAndPort.fromString(getHttpsRequestHostAndPort());
        serverHost = hostAndPort.getHost();
    } else {
        serverHost = HttpUtil.getHostFromRequest(modifiedRequest);
    }
    return serverHost;
}