{"record":{"id":"febd9edf39f6d1d7","repo":"zaproxy/zaproxy","slug":"failed-to-find-pattern","errorCode":null,"errorMessage":"Failed to find pattern: ","messagePattern":"Failed to find pattern: ","errorType":"exception","errorClass":"HttpMalformedHeaderException","httpStatus":null,"severity":"error","filePath":"zap/src/main/java/org/parosproxy/paros/network/HttpResponseHeader.java","lineNumber":212,"sourceCode":"    /**\n     * Sets the reason phrase.\n     *\n     * <p>If {@code null} it's set an empty string.\n     *\n     * @param reasonPhrase the new reason phrase.\n     * @see #getReasonPhrase()\n     * @since 2.7.0\n     */\n    public void setReasonPhrase(String reasonPhrase) {\n        this.mReasonPhrase = reasonPhrase != null ? reasonPhrase : \"\";\n    }\n\n    private void parse() throws HttpMalformedHeaderException {\n\n        Matcher matcher = patternStatusLine.matcher(mStartLine);\n        if (!matcher.find()) {\n            mMalformedHeader = true;\n            throw new HttpMalformedHeaderException(\"Failed to find pattern: \" + patternStatusLine);\n        }\n\n        mVersion = matcher.group(1);\n        mStatusCodeString = matcher.group(2);\n        setReasonPhrase(matcher.group(3));\n\n        try {\n            mStatusCode = Integer.parseInt(mStatusCodeString);\n        } catch (NumberFormatException e) {\n            mMalformedHeader = true;\n            throw new HttpMalformedHeaderException(\"Unexpected status code: \" + mStatusCodeString);\n        }\n    }\n\n    @Override\n    public int getContentLength() {\n        int len = super.getContentLength();\n","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/zaproxy/zaproxy/blob/9d1970a436b1b189bfb588fc88864c80d9baf6a5/zap/src/main/java/org/parosproxy/paros/network/HttpResponseHeader.java#L194-L230","documentation":"HttpMalformedHeaderException thrown by HttpResponseHeader.parse when the status line does not match the expected HTTP/version status-code pattern. The response bytes at fault are not a valid HTTP response start line (e.g. garbage, HTML error page from a non-HTTP service).","triggerScenarios":"Thrown at zap/src/main/java/org/parosproxy/paros/network/HttpResponseHeader.java:212 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check you are connecting to an HTTP service on the expected port","Catch HttpMalformedHeaderException and treat the message as non-HTTP","Validate raw response bytes before wrapping in HttpResponseHeader"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d1970a436b1b189bfb588fc88864c80d9baf6a5","analyzedAt":"2026-09-05T19:26:59.356Z","contentChangedAt":"2026-09-05T19:26:59.356Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}