@Before public void setupHttpRequest() { when(httpRequest.getPath()).thenReturn(REQUEST_PATH); when(httpRequest.getHeader("User-Agent")).thenReturn(USER_AGENT); when(httpRequest.getHeader("Path")).thenReturn(HEADER_PATH); }
public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException { PageNode page = ctx.getPageMaker().getPageNode("Redirect to Decoded link", ctx); HTMLNode pageNode = page.outer; HTMLNode contentNode = page.content; if(ctx.isAllowedFullAccess()) contentNode.addChild(ctx.getAlertManager().createSummary()); final String requestPath = request.getPath().substring(path().length()); //Without this it'll try to look in the current directory which will be /decode and won't work. String keyToFetch = "/" + requestPath; // This is for when a browser can't handle 301s, should very rarely (never?) be seen. ctx.getPageMaker().getInfobox("infobox-warning", "Decode Link", contentNode, "decode-not-redirected", true). addChild("a", "href", keyToFetch, "Click Here to be re-directed"); this.writeHTMLReply(ctx, 301, "Moved Permanently\nLocation: "+ keyToFetch, pageNode.generate()); }
String path = request.getPath();
final String requestPath = request.getPath().substring(path().length());
return; String path=request.getPath();
final String requestPath = request.getPath().substring(path().length());