Package 

Class HttpProxyCacheServer


  • 
    public class HttpProxyCacheServer
    
                        

    Simple lightweight proxy server with file caching support that handles HTTP requests. Typical usage:

     public onCreate(Bundle state) { super.onCreate(state); HttpProxyCacheServer proxy = getProxy(); String proxyUrl = proxy.getProxyUrl(VIDEO_URL); videoView.setVideoPath(proxyUrl); } private HttpProxyCacheServer getProxy() { // should return single instance of HttpProxyCacheServer shared for whole app. } 
    • Constructor Detail

      • HttpProxyCacheServer

        HttpProxyCacheServer(Context context)
    • Method Detail

      • getProxyUrl

         String getProxyUrl(String url)

        Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).

        If file for this url is fully cached (it means method isCached returns {@code true})then file:// uri to cached file will be returned.

        Calling this method has same effect as calling getProxyUrl with 2nd parameter set to {@code true}.

        Parameters:
        url - a url to file that should be cached.
      • getProxyUrl

         String getProxyUrl(String url, boolean allowCachedFileUri)

        Returns url that wrap original url and should be used for client (MediaPlayer, ExoPlayer, etc).

        If parameter {@code allowCachedFileUri} is {@code true} and file for this url is fully cached(it means method isCached returns {@code true}) then file:// uri to cached file will be returned.

        Parameters:
        url - a url to file that should be cached.
        allowCachedFileUri - {@code true} if allow to return file:// uri if url is fully cached
      • isCached

         boolean isCached(String url)

        Checks is cache contains fully cached file for particular url.

        Parameters:
        url - an url cache file will be checked for.