All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.sb1.troxy.util.RequestInterceptor Maven / Gradle / Ivy

Go to download

Troxy is a proxy intended for simulating a remote service without actually connecting to the server. Incoming requests are matched using regular expressions and responses are created from a recorded response from the remote service and optionally modified by inserting values caught from the regular expression used to match the request.

There is a newer version: 3.2.49
Show newest version
package no.sb1.troxy.util;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;

/**
 * This "Handler" only saves who have used Troxy and when.
 */
public class RequestInterceptor extends AbstractHandler {
    private static Map lastUsers = new HashMap<>();

    public static Map getLastUsers() {
        return lastUsers;
    }

    @Override
    public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
        lastUsers.put(request.getRemoteAddr(), new Date());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy