private void AnalizeURI(LoadTestDatabase db, UriInfo u) { switch (GetExtension(u.Target)) { case ".txt": //Sai sem analizar return; break; } Console.WriteLine("ContentAnalizer> " + u.Target); Console.Write("\tBaixando: "); ResultData request = Request.GetRequest(u.Target, this.Proxy, false, HTTPHeaders); if (request.Error) { Console.WriteLine("Err " + request.ErrorMessage); db.insertMessages(this.TestName, "3. Erro na chamada de URL", "URL: <a href=\"" + u.Target.AbsoluteUri + "\" target=\"_blank\">" + u.Target.AbsoluteUri + "</a>" + Environment.NewLine + (u.Referer != null ? "Referer: <a href=\"" + u.Referer.AbsoluteUri + "\" target=\"_blank\">" + u.Referer.AbsoluteUri + "</a>" + Environment.NewLine : "") + Environment.NewLine + "Tempo de resposta: " + FileResources.formatData(request.Time.TotalMilliseconds, ChartDataType.Integer) + "ms " + Environment.NewLine + "Código de retorno HTTP: " + request.Code + Environment.NewLine + Environment.NewLine + (!String.IsNullOrEmpty(request.ErrorMessage) ? "Texto do erro: " + request.ErrorMessage : "")); } else { Console.WriteLine("OK " + request.DataLength); Console.Write("\tVerificando: "); //Tempo de resposta if (request.Time.TotalMilliseconds > 1500F) { db.insertMessages(this.TestName, "2. Alto tempo de resposta", "URL: <a href=\"" + u.Target.AbsoluteUri + "\" target=\"_blank\">" + u.Target.AbsoluteUri + "</a>" + Environment.NewLine + (u.Referer != null ? "Referer: <a href=\"" + u.Referer.AbsoluteUri + "\" target=\"_blank\">" + u.Referer.AbsoluteUri + "</a>" + Environment.NewLine : "") + Environment.NewLine + "Tempo de resposta: " + FileResources.formatData(request.Time.TotalMilliseconds, ChartDataType.Integer) + " ms"); } String extension = GetExtension(u.Target); if (!MIMECheck.CheckMime(request.ContentType.ToLower(), extension)) { db.insertMessages(this.TestName, "4. ContentType inválido", "URL: <a href=\"" + u.Target.AbsoluteUri + "\" target=\"_blank\">" + u.Target.AbsoluteUri + "</a>" + Environment.NewLine + (u.Referer != null ? "Referer: <a href=\"" + u.Referer.AbsoluteUri + "\" target=\"_blank\">" + u.Referer.AbsoluteUri + "</a>" + Environment.NewLine : "") + Environment.NewLine + "Extensão: " + extension + Environment.NewLine + "MIME Type: " + request.ContentType); } if ((request.OriginalDataLength > 0) && (request.OriginalDataLength < request.DataLength)) { db.insertGzipOptimization(this.TestName, request.RequestUri, request.OriginalDataLength, request.DataLength); } else if ((request.OriginalDataLength > 0) && (request.OriginalDataLength == request.DataLength)) { //Realiza a compactação Gzip para estimar a otimização Byte[] tmp = GzipCompress(request.Data); double percent = 100F - (((double)tmp.Length / (double)request.DataLength) * 100F); if (percent > 10) { db.insertMessages(this.TestName, "7. Otimização de rede (compactação gzip/deflate)", "URL: <a href=\"" + u.Target.AbsoluteUri + "\" target=\"_blank\">" + u.Target.AbsoluteUri + "</a>" + Environment.NewLine + (u.Referer != null ? "Referer: <a href=\"" + u.Referer.AbsoluteUri + "\" target=\"_blank\">" + u.Referer.AbsoluteUri + "</a>" + Environment.NewLine : "") + Environment.NewLine + "Redução estimada de: " + FileResources.formatData(percent, ChartDataType.Percent) + Environment.NewLine + "Tamanho original: " + FileResources.formatData(request.DataLength, ChartDataType.Bytes) + Environment.NewLine + "Tamanho reduzido: " + FileResources.formatData(tmp.Length, ChartDataType.Bytes)); } } //Consições específicas por conteúdo switch (request.ContentType.ToLower()) { case "application/x-pointplus": case "text/css": Check(db, CheckType.Css, u, request); break; case "application/x-javascript": case "application/javascript": case "application/ecmascript": case "text/javascript": case "text/ecmascript": Check(db, CheckType.JS, u, request); break; case "image/png": Check(db, CheckType.Image, u, request); break; default: //Verifica por extenção switch (extension) { case ".css": Check(db, CheckType.Css, u, request); break; case ".js": Check(db, CheckType.JS, u, request); break; case ".png": case ".jpg": case ".gif": Check(db, CheckType.Image, u, request); break; } break; } Console.WriteLine("OK"); } }