Skip to content

Commit d0987fa

Browse files
committed
Handle absolute parameter in redirect endpoint
Found via python httpbin tests.
1 parent 9c35d5d commit d0987fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/org/gaul/httpbin/HttpBinHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,16 @@ baos, new Deflater(Deflater.DEFAULT_COMPRESSION,
416416
int count = Integer.parseInt(uri.substring(
417417
"/redirect/".length())) - 1;
418418
if (count > 0) {
419-
redirectTo(servletResponse, "/redirect/" + count);
419+
StringBuilder path = new StringBuilder();
420+
if ("true".equals(request.getParameter("absolute"))) {
421+
path.append(request.getRequestURL());
422+
path.setLength(path.length() - uri.length());
423+
path.append("/absolute-redirect/");
424+
} else {
425+
path.append("/relative-redirect/");
426+
}
427+
path.append(count);
428+
redirectTo(servletResponse, path.toString());
420429
} else {
421430
redirectTo(servletResponse, "/get");
422431
}

0 commit comments

Comments
 (0)