{"record":{"id":"6621ebb15957ecdd","repo":"valyala/fasthttp","slug":"malformed-mime-header-missing-colon-q","errorCode":null,"errorMessage":"malformed mime header: missing colon: %q","messagePattern":"malformed mime header: missing colon: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"headerscanner.go","lineNumber":121,"sourceCode":"\t}\n\treturn line\n}\n\n// readContinuedLineSlice reads continued lines from b until it finds a line\n// that does not start with a space or tab, or it reaches the end of b.\n// It also returns the position of the first colon in the returned line:\n// the line can never start with a space or tab (the scanner rejects that for\n// the first line and joins such lines into the previous header), so trimming\n// it doesn't shift the colon.\nfunc (s *headerScanner) readContinuedLineSlice() ([]byte, int, error) {\n\tline := s.readLine()\n\tif len(line) == 0 { // blank line - no continuation\n\t\treturn line, -1, nil\n\t}\n\n\tcolon := bytes.IndexByte(line, ':')\n\tif colon < 0 {\n\t\treturn nil, -1, fmt.Errorf(\"malformed mime header: missing colon: %q\", line)\n\t}\n\n\t// If the next line doesn't start with a space or tab, we are done.\n\tif len(s.b)-s.r > 1 {\n\t\tpeek := s.b[s.r : s.r+2]\n\t\tif len(peek) > 0 && (isASCIILetter(peek[0]) || peek[0] == '\\n') ||\n\t\t\tlen(peek) == 2 && peek[0] == '\\r' && peek[1] == '\\n' {\n\t\t\treturn trim(line), colon, nil\n\t\t}\n\t}\n\n\tmline := trim(line)\n\n\t// Read continuation lines.\n\tfor s.skipSpace() {\n\t\tmline = append(mline, ' ')\n\t\tline := s.readLine()\n\t\tmline = append(mline, trim(line)...)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/headerscanner.go#L103-L139","documentation":"readContinuedLineSlice in the header scanner requires every header line to contain a colon separating key from value; a non-empty line without any colon is not a valid MIME header line and aborts scanning with this error.","triggerScenarios":"A header block line like 'garbageline\\r\\n' with no colon, e.g. leftover body bytes interpreted as headers, a truncated request, or continuation lines without a base 'key:' line.","commonSituations":"Pipelined/partial writes corrupting the header/body boundary; requests where the body starts before headers ended (wrong Content-Length); fuzzing or scanner traffic.","solutions":["Fix Content-Length or chunked framing so body bytes are not parsed as headers.","Ensure every header line contains 'key: value' with a colon.","Check for premature request pipelining or stream desynchronization in your client.","Log the offending line (%q in the error) to identify the corrupted part of the stream."],"exampleFix":"// before (raw write missing colon)\nc.Write([]byte(\"justtext\\r\\n\\r\\n\"))\n// after\nc.Write([]byte(\"X-Note: justtext\\r\\n\\r\\n\"))","handlingStrategy":"validation","validationCode":"func lineHasColon(line []byte) bool { return bytes.IndexByte(line, ':') >= 0 }\n// validate every raw header line before writing it to the wire","typeGuard":null,"tryCatchPattern":"if err := scanner step err; err != nil && strings.Contains(err.Error(), \"missing colon\") {\n    // framing is desynchronized: close connection, do not attempt recovery\n}","preventionTips":["Verify Content-Length matches actual body size to avoid body-as-header corruption","Ensure every header line includes a colon","Avoid hand-writing raw HTTP bytes; use the library's request APIs"],"tags":["http","fasthttp","mime-header","malformed"],"backgroundTag":"malformed-mime-header","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}