Some examples to illustrate the bug...
This snippet from a servlet's doGet() method displays the returned headers
for a redirect as expected. This happens on BOTH the dev server and the
production server because it's responding with a redirect to use HTTPS:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
String page = "http://mytlc.bestbuy.com/etm/";
URL url = new URL(page);
out.println("Requesting: "+page);
HttpURLConnection conn = ((HttpURLConnection)url.openConnection());
conn.setInstanceFollowRedirects(false);
BufferedReader reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
StringBuilder output = new StringBuilder();
Map<String, List<String>> headers = conn.getHeaderFields();
Object[] keys = headers.keySet().toArray();
//Print the headers
for(int i = 0; i < keys.length; i++){
out.print(keys[i]+": ");
List<String> headerValues = headers.get(keys[i]);
for(int n = 0; n < headerValues.size(); n++){
out.print(headerValues.get(n)+", ");
}
out.println();
}
//Print the content
String line;
while ((line = reader.readLine()) != null) {
output.append(line+"\n");
}
resp.getWriter().print(output.toString());
}
Now change the "page" variable to "https://mytlc.bestbuy.com/etm/" so now
it's requesting via HTTPS. When executed from the dev server, this pulls the
web page as it normally should (and very quickly), but on the production
server it causes a timeout every time. Now the tlc.bestbuy.com site uses a
certificate that isn't always verifiable, depending on whether or not the
client has the required intermediate CA, which could be causing the timeout.
In such a situation, you can specify that no attempts to verify certificates
should be made. Unfortunately, that doesn't work; it continues to time out.
Here is my attempt to bypass certificate verification:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
String page = "https://mytlc.bestbuy.com/etm/";
FetchOptions fetchOptions =
FetchOptions.Builder.allowTruncate().doNotValidateCertificate();
HTTPMethod httpMethod = HTTPMethod.GET;
URLFetchService fetchService =
URLFetchServiceFactory.getURLFetchService();
HTTPRequest httpRequest = new HTTPRequest(new URL(page), httpMethod,
fetchOptions);
HTTPResponse httpResponse = fetchService.fetch(httpRequest);
out.print(new String(httpResponse.getContent()));
}
Here is the time out exception:
Uncaught exception from servlet
java.io.IOException: Timeout while fetching: https://mytlc.bestbuy.com/etm/
at
com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:112)
at
com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:41)
at com.langhart.tlcgcu.TestServlet.doGet(TestServlet.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at
com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at
com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at
com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:261)
at
com.google.apphosting.base.RuntimePb$EvaluationRuntime$2.handleRequest(RuntimePb.java:9285)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:437)
at com.google.net.rpc.impl.Server$RpcTask.runInContext(Server.java:573)
at
com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:448)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:688)
at
com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:326)
at
com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:318)
at
com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:446)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.