Class LocalURLFetchServiceStreamHandler

java.lang.Object
java.net.URLStreamHandler
com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler
com.google.appengine.tools.development.LocalURLFetchServiceStreamHandler

public class LocalURLFetchServiceStreamHandler extends com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler
Extension to URLFetchServiceStreamHandler that can fall back to a default stream handler when the url fetch service is not available.

The Dev AppServer registers a custom stream handler, which is global (not classloader global, jvm global). In addition, the jdk only lets you set a custom stream handler once, so once it's set, it's set. This is unfortunate, because you may have a program like an integration test or a remote api test that spends some time operating in an App Engine context and some time operating in a non-App Engine context. Without the ability to fall back to a default stream handler, you are effectively prevented from doing anything involving stream handlers once you stop operating in an App Engine context.

  • Constructor Details

    • LocalURLFetchServiceStreamHandler

      public LocalURLFetchServiceStreamHandler(@Nullable URLStreamHandler fallbackHandler)
      Constructs a LocalURLFetchServiceStreamHandler
      Parameters:
      fallbackHandler - Receives requests to open connections when the url fetch service is not available.
  • Method Details

    • getFallbackHandler

      public URLStreamHandler getFallbackHandler()
    • setUseNativeHandlers

      public static void setUseNativeHandlers(boolean useNativeHandlers)