Search in sources :

Example 26 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ScriptsImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    ScriptsResult result = new ScriptsResult();
    for (Session session : tracedata.getSessionlist()) {
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.RESPONSE && req.getContentLength() > 0 && req.getContentType() != null && reqhelper.isHtml(req.getContentType())) {
                result = analyzeHtml(req, session, result);
            }
        }
    }
    String text = "";
    if (result.getFirstFailedHtml() == null) {
        result.setResultType(BPResultType.PASS);
        text = MessageFormat.format(textResultPass, result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), result.getNumberOfFailedFiles());
        result.setResultText(text);
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), result.getNumberOfFailedFiles()));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllNumberOfScriptsFiles(exportAllNumberOfScriptsFiles);
    return result;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ScriptsResult(com.att.aro.core.bestpractice.pojo.ScriptsResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 27 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class Http4xx5xxImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    Http4xx5xxResult result = new Http4xx5xxResult();
    Map<Integer, HttpRequestResponseInfo> firstErrorRespMap4XX = new HashMap<Integer, HttpRequestResponseInfo>();
    SortedMap<Integer, Integer> httpErrorCounts4XX = new TreeMap<Integer, Integer>();
    List<Http4xx5xxStatusResponseCodesEntry> httpResCodelist = new ArrayList<Http4xx5xxStatusResponseCodesEntry>();
    HttpRequestResponseInfo lastRequestObj = null;
    for (Session session : tracedata.getSessionlist()) {
        lastRequestObj = null;
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.REQUEST) {
                lastRequestObj = req;
            }
            if (req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 400 && req.getStatusCode() < 600) {
                Integer code = req.getStatusCode();
                Integer count = httpErrorCounts4XX.get(code);
                if (count != null) {
                    httpErrorCounts4XX.put(code, count + 1);
                } else {
                    httpErrorCounts4XX.put(code, 1);
                    firstErrorRespMap4XX.put(code, req);
                }
                httpResCodelist.add(new Http4xx5xxStatusResponseCodesEntry(req, lastRequestObj, session.getDomainName()));
            }
        }
    }
    if (httpErrorCounts4XX.isEmpty()) {
        result.setResultType(BPResultType.PASS);
        result.setResultText(textResultPass);
        result.setResultExcelText(BPResultType.PASS.getDescription());
    } else {
        result.setResultType(BPResultType.FAIL);
        result.setResultText(Http3xx4xxHelper.createFailResult(httpErrorCounts4XX, textResults, errorPlural, errorSingular));
        result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), Http3xx4xxHelper.formatErrorCodesToText(httpErrorCounts4XX)));
    }
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAllHttpError(exportAllHttpError);
    result.setFirstErrorRespMap4XX(firstErrorRespMap4XX);
    result.setHttpErrorCounts4XX(httpErrorCounts4XX);
    result.setHttpResCodelist(httpResCodelist);
    return result;
}
Also used : Http4xx5xxStatusResponseCodesEntry(com.att.aro.core.bestpractice.pojo.Http4xx5xxStatusResponseCodesEntry) HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Http4xx5xxResult(com.att.aro.core.bestpractice.pojo.Http4xx5xxResult) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 28 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ImageCompressionImpl method compressImages.

private void compressImages() {
    ExecutorService exec = Executors.newFixedThreadPool(5);
    for (final Session session : packetResult.getSessionlist()) {
        for (final HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
                String extractedImage = ImageHelper.extractFullNameFromRRInfo(req);
                if ((!extractedImage.isEmpty() && !(extractedImage.contains(".jpeg") || extractedImage.contains(".jpg"))) && req.getContentType().contains("jpeg")) {
                    extractedImage = Util.parseImageName(extractedImage, req);
                }
                File imgFile = new File(imageFolderPath + extractedImage);
                if (imgFile.exists() && !imgFile.isDirectory()) {
                    int posExtn = extractedImage.lastIndexOf(".");
                    String imgExtn = extractedImage.substring(posExtn + 1, extractedImage.length());
                    if (Util.isJPG(imgFile, imgExtn)) {
                        final String imageFile = extractedImage;
                        exec.submit(new Runnable() {

                            @Override
                            public void run() {
                                compressImage(imageFolderPath, imageFile);
                            }
                        });
                    }
                }
            }
        }
    }
    try {
        // Time out after 10 minutes
        exec.shutdown();
        exec.awaitTermination(10, TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 29 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class SimultnsUtil method createDomainsTCPSessions.

public List<SessionValues> createDomainsTCPSessions(Collection<Session> allTCPSessions) {
    List<SessionValues> sessionValues = new ArrayList<SessionValues>();
    Session lastSession = null;
    for (Session aSession : allTCPSessions) {
        if (aSession != null) {
            if (!aSession.getRequestResponseInfo().isEmpty()) {
                for (HttpRequestResponseInfo req : aSession.getRequestResponseInfo()) {
                    sessionValues = addSessionValues(sessionValues, lastSession, aSession, req);
                    lastSession = aSession;
                }
            } else {
                HttpRequestResponseInfo reqResp = new HttpRequestResponseInfo();
                if (aSession.getRemoteHostName() != null) {
                    reqResp.setHostName(aSession.getRemoteHostName());
                    reqResp.setFirstDataPacket(aSession.getTcpPackets().get(0));
                }
                sessionValues = addSessionValues(sessionValues, lastSession, aSession, reqResp);
            }
        }
    }
    return sessionValues;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) SessionValues(com.att.aro.core.packetanalysis.pojo.SessionValues) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 30 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class MultipleConnectionsEntry method assignHostAndHttpInfo.

private void assignHostAndHttpInfo(HttpRequestResponseInfo httpReqResp, String hostName) {
    HttpRequestResponseInfo respons = httpReqResp.getAssocReqResp();
    if (respons != null) {
        if (respons.getHostName() == null || respons.getHostName().isEmpty()) {
            if (httpReqResp.getHostName() == null || httpReqResp.getHostName().isEmpty()) {
                this.hostName = hostName;
            } else {
                this.hostName = httpReqResp.getHostName();
            }
        } else {
            this.hostName = respons.getHostName();
        }
        this.httpReqObjName = respons.getObjName();
    } else {
        if (httpReqResp.getHostName() == null || httpReqResp.getHostName().isEmpty()) {
            this.hostName = hostName;
        } else {
            this.hostName = httpReqResp.getHostName();
        }
    }
    String hostNameObj = this.hostName;
    if (hostNameObj.contains("/")) {
        this.hostName = hostNameObj.substring(hostNameObj.lastIndexOf('/') + 1, hostNameObj.length());
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4