public ContentResponse(ContentStorage content, Uri uri) { _content = content; _status = HttpStatusCode.InternalServerError; _record = ContentRecord.DefaultInstance; try { string path = uri.NormalizedPathAndQuery(); if (_content.TryGetValue(path, out _record)) { if (_record.HasContentRedirect) _status = HttpStatusCode.Redirect; else _status = HttpStatusCode.OK; } else { _record = ContentRecord.DefaultInstance; _status = HttpStatusCode.NotFound; Log.Warning("404 - {0}", path); } } catch (Exception ex) { Log.Error(ex, "Exception on {0}", uri); } }
void ContextChanged(ContentRecord obj) { _context = obj; _elements.Clear(); }
public XmlRewriter(ContentParser processor, HttpCloneOptimizations optimizations, IDictionary<string, string> namedValues) { _context = ContentRecord.DefaultInstance; _processor = processor; _optimizations = optimizations; _namedValues = namedValues; _elements = new Dictionary<XmlLightElement, object>(); _replaces = new Dictionary<object, HttpCloneOptimizationReplace>(); foreach (var rep in optimizations.AllItems()) foreach (var i in rep.ReplaceItem) _replaces.Add(i, rep); _bytag = optimizations.AllItems() .SelectMany(item => item.ReplaceItem.OfType<HttpCloneTag>()) .ToLookup(t => t.TagName); _xpaths = optimizations.AllItems() .SelectMany(item => item.ReplaceItem.OfType<HttpCloneXPath>()) .ToArray(); if (_bytag.Count > 0 || _xpaths.Length > 0) { processor.ContextChanged += ContextChanged; processor.RewriteElement += RewriteElement; processor.RewriteXmlDocument += RewriteXmlDocument; } }
void ContextChanged(ContentRecord obj) { _context = obj; }
private void ProcessFileContent(ContentRecord record, byte[] contentBytes) { if(AddUrlsFound) _parser.ProcessFile(record, contentBytes); }