public void WillReturn304WhenRequestigResourcewithEtag() { new WebClient().DownloadString("http://*****:*****@"(href|src)=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase); var cssUrlurl = "http://localhost:8877" + urlPattern.Match(css).Groups["url"].Value; var httpResponse = WebRequest.Create(cssUrlurl).GetResponse(); var etag = httpResponse.Headers["ETag"]; httpResponse.Close(); var request = WebRequest.Create(cssUrlurl); request.Headers["If-None-Match"] = etag; var ex = Record.Exception(() => request.GetResponse()) as WebException; Assert.Equal(HttpStatusCode.NotModified, (ex.Response as HttpWebResponse).StatusCode); }
public void WillUseSameReductionAfterAppPoolRecycle() { var urlPattern = new Regex(@"(href|src)=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase); new WebClient().DownloadString("http://localhost:8877/Local.html"); WaitToCreateResources(); var response = new WebClient().DownloadString("http://localhost:8877/Local.html"); var css = new CssResource().ResourceRegex.Match(response).ToString(); var js = new JavaScriptResource().ResourceRegex.Match(response).ToString(); var urls = new string[] { urlPattern.Match(css).Groups["url"].Value, urlPattern.Match(js).Groups["url"].Value }; var files = new string[] { urls[0].Replace("/RRContent", rrFolder).Replace("/", "\\"), urls[1].Replace("/RRContent", rrFolder).Replace("/", "\\") }; var createTime = new DateTime[] { new FileInfo(files[0]).LastWriteTime, new FileInfo(files[1]).LastWriteTime }; IntegrationFactHelper.RecyclePool(); new WebClient().DownloadString("http://localhost:8877/Local.html"); WaitToCreateResources(); Assert.Equal(createTime[0], new FileInfo(files[0]).LastWriteTime); Assert.Equal(createTime[1], new FileInfo(files[1]).LastWriteTime); }
public void WillSetCacheHeadersOnCssContent() { var urlPattern = new Regex(@"(href|src)=""?(?<url>[^"" ]+)""?[^ />]+[ />]", RegexOptions.IgnoreCase); string url; using (var client = new WebClient()) { client.DownloadString("http://*****:*****@"""{0}""", uriBuilder.ParseSignature(url)), response2.Headers["ETag"]); response2.Close(); }