Skip to content

Instantly share code, notes, and snippets.

@6londe
Last active January 8, 2016 04:41
Show Gist options
  • Save 6londe/28a900c7bebb21f61a5e to your computer and use it in GitHub Desktop.
Save 6londe/28a900c7bebb21f61a5e to your computer and use it in GitHub Desktop.
url: bypass.jsp?http://some.url
<%@page session="false"%>
<%@page import="java.net.*,java.io.*"%>
<%
try {
String reqUrl = request.getQueryString();
URL url = new URL(reqUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod(request.getMethod());
int clength = request.getContentLength();
if (clength > 0) {
con.setDoInput(true);
byte[] idata = new byte[clength];
request.getInputStream().read(idata, 0, clength);
con.getOutputStream().write(idata, 0, clength);
}
response.setContentType(con.getContentType());
BufferedReader rd = new BufferedReader(new InputStreamReader(
con.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
out.println(line);
}
rd.close();
} catch (Exception e) {
System.out.println(e.getMessage());
response.setStatus(500);
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment