{"record":{"id":"adba538133168328","repo":"projectdiscovery/nuclei","slug":"malformed-raw-http-response","errorCode":null,"errorMessage":"malformed raw http response","messagePattern":"malformed raw http response","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/offlinehttp/read_response.go","lineNumber":30,"sourceCode":"\n// readResponseFromString reads a raw http response from a string.\nfunc readResponseFromString(data string) (*http.Response, error) {\n\t// Check if \"data\" contains RFC compatible Request followed by a response\n\tbr := bufio.NewReader(strings.NewReader(data))\n\tif req, err := http.ReadRequest(br); err == nil {\n\t\tif resp, err := http.ReadResponse(br, req); err == nil {\n\t\t\treturn resp, nil\n\t\t}\n\t}\n\n\t// otherwise tries to patch known cases such as http minor version\n\tvar final string\n\tif strings.HasPrefix(data, \"HTTP/\") {\n\t\tfinal = addMinorVersionToHTTP(data)\n\t} else {\n\t\tlastIndex := strings.LastIndex(data, \"HTTP/\")\n\t\tif lastIndex == -1 {\n\t\t\treturn nil, errors.New(\"malformed raw http response\")\n\t\t}\n\t\tfinal = data[lastIndex:] // choose last http/ in case of it being later.\n\n\t\tfinal = addMinorVersionToHTTP(final)\n\t}\n\treturn http.ReadResponse(bufio.NewReader(strings.NewReader(final)), nil)\n}\n\n// addMinorVersionToHTTP tries to add a minor version to http status header\n// fixing the compatibility issue with go standard library.\nfunc addMinorVersionToHTTP(data string) string {\n\tmatches := noMinor.FindAllStringSubmatch(data, 1)\n\tif len(matches) == 0 {\n\t\treturn data\n\t}\n\tif len(matches[0]) < 2 {\n\t\treturn data\n\t}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/offlinehttp/read_response.go#L12-L48","documentation":"Error \"malformed raw http response\" thrown in projectdiscovery/nuclei.","triggerScenarios":"Thrown at pkg/protocols/offlinehttp/read_response.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}