private void Initialize(HttpContext context, PortalContextInitInfo initInfo) { _ownerHttpContext = context; // use absolute uri to clone. requesturi.tostring messes up encoded parts, like backurl _originalUri = new Uri(initInfo.RequestUri.AbsoluteUri.ToString()); // clone _isWebdavRequest = initInfo.IsWebdavRequest; _isOfficeProtocolRequest = initInfo.IsOfficeProtocolRequest; _basicAuthHeaders = initInfo.BasicAuthHeaders; _site = initInfo.RequestedSite; _siteUrl = initInfo.SiteUrl; _siteRelativePath = initInfo.SiteRelativePath; _repositoryPath = initInfo.RepositoryPath; _actionName = initInfo.ActionName; _appNodePath = initInfo.AppNodePath; _contextNodePath = initInfo.ContextNodePath; _versionRequest = initInfo.VersionRequest; _deviceName = initInfo.DeviceName; if (_contextNodePath == null) { _contextNodeHead = initInfo.RequestedNodeHead; } else { _contextNodeHead = NodeHead.Get(initInfo.ContextNodePath); _appNodePath = initInfo.RequestedNodeHead.Path; } //if (_siteUrl != null) // _authenticationMode = _site.UrlList[siteUrl]; _authenticationMode = GetCurrentAuthenticationMode(); if (_contextNodeHead != null /*_isRequestedResourceExistInRepository*/) { _nodeType = initInfo.RequestedNodeHead.GetNodeType(); _nodeId = initInfo.RequestedNodeHead.Id; } //_queryStringNodePropertyName = HttpContext.Current.Request.QueryString[QUERYSTRING_NODEPROPERTY_KEY]; _queryStringNodePropertyName = context.Request.QueryString[QUERYSTRING_NODEPROPERTY_KEY]; if (_queryStringNodePropertyName != null) _queryStringNodePropertyName = _queryStringNodePropertyName.Replace('$', '#'); BinaryHandlerRequestedNodeHead = initInfo.BinaryHandlerRequestedNodeHead; }
internal static PortalContext Create(HttpContext context, PortalContextInitInfo initInfo) { PortalContext pc = new PortalContext(); pc.Initialize(context, initInfo); context.Items.Add(CONTEXT_ITEM_KEY, pc); context.Items.Add(ApplicationStorage.DEVICEPARAMNAME, pc.DeviceName); return pc; }
private void HandleResponseForClientCache(PortalContextInitInfo initInfo) { var context = HttpContext.Current; // binaryhandler if (_binaryHandlerClientCacheMaxAge.HasValue && initInfo.BinaryHandlerRequestedNodeHead != null) { HttpHeaderTools.SetCacheControlHeaders(_binaryHandlerClientCacheMaxAge.Value); // handle is-modified-since requests only for requests coming from proxy if (PortalContext.ProxyIPs.Contains(context.Request.UserHostAddress)) HttpHeaderTools.EndResponseForClientCache(initInfo.BinaryHandlerRequestedNodeHead.ModificationDate); return; } // images, and other content requested with their path (e.g. /Root/Global/images/myimage.png) string extension = System.IO.Path.GetExtension(context.Request.Url.AbsolutePath).ToLower(); if (_clientCacheConfig != null && _clientCacheConfig.ContainsKey(extension)) { // get requested nodehead if (initInfo.RequestedNodeHead == null) return; int seconds = _clientCacheConfig[extension]; HttpHeaderTools.SetCacheControlHeaders(seconds); // handle is-modified-since requests only for requests coming from proxy if (PortalContext.ProxyIPs.Contains(context.Request.UserHostAddress)) HttpHeaderTools.EndResponseForClientCache(initInfo.RequestedNodeHead.ModificationDate); return; } // applications if (initInfo.RequestedNodeHead != null) { Application app = null; // elevate to sysadmin, as we are startupuser here, and group 'everyone' should have permissions to application without elevation using (new SystemAccount()) { app = ApplicationStorage.Instance.GetApplication(string.IsNullOrEmpty(initInfo.ActionName) ? "browse" : initInfo.ActionName, initInfo.RequestedNodeHead, initInfo.DeviceName); } if (app != null) { var maxAge = app.NumericMaxAge; var cacheControl = app.CacheControlEnumValue; if (cacheControl.HasValue && maxAge.HasValue) { HttpHeaderTools.SetCacheControlHeaders(maxAge.Value, cacheControl.Value); if (PortalContext.ProxyIPs.Contains(context.Request.UserHostAddress)) HttpHeaderTools.EndResponseForClientCache(initInfo.RequestedNodeHead.ModificationDate); } return; } } }