예제 #1
0
        public MessageBundle getBundle(GadgetSpec spec, Locale locale, bool ignoreCache)
        {
            if (ignoreCache)
            {
                return getNestedBundle(spec, locale, true);
            }

            String key = spec.getUrl().ToString() + '.' + locale.ToString();

            MessageBundle cached = HttpRuntime.Cache[key] as MessageBundle;

            MessageBundle bundle;
            if (cached == null)
            {
                try
                {
                    bundle = getNestedBundle(spec, locale, ignoreCache);
                }
                catch (GadgetException)
                {
                    // Enforce negative caching.
                    bundle = cached ?? MessageBundle.EMPTY;
                }
                HttpRuntime.Cache.Insert(key, bundle, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(refresh));
            }
            else
            {
                bundle = cached;
            }

            return bundle;
        }
예제 #2
0
        /**
         * @param concatBase Base url of the Concat servlet. Expected to be of the
         *                   form www.host.com/concat?
         * @param relativeUrlBase to resolve relative urls
         */
        public JavascriptTagMerger(GadgetSpec spec, ContentRewriterFeature rewriterFeature,
                                   String concatBase, Uri relativeUrlBase)
        {
            // Force the mime-type to mimic browser expectation so rewriters
            // can function properly
            this.concatBase = concatBase
                              + ProxyBase.REWRITE_MIME_TYPE_PARAM
                              + "=text/javascript&"
                              + "gadget="
                              + HttpUtility.UrlEncode(spec.getUrl().ToString())
                              + "&fp="
                              + rewriterFeature.getFingerprint()
                              + '&';

            this.relativeUrlBase = relativeUrlBase;
        }
예제 #3
0
 private String GetLockedDomain(GadgetSpec gadget, String container)
 {
     String suffix;
     if (!lockedSuffixes.TryGetValue(container, out suffix))
     {
         return null;
     }
     String hash = SHA1.Create().ComputeHash(Encoding.Default.GetBytes(gadget.getUrl().ToString())).ToString();
     return hash + suffix;
 }
예제 #4
0
 protected internal ILinkRewriter CreateLinkRewriter(GadgetSpec spec, ContentRewriterFeature rewriterFeature)
 {
     return new ProxyingLinkRewriter(spec.getUrl(), rewriterFeature, ProxyUrl);
 }