projectdiscovery/nuclei · error

failed to read method line: %s

Error message

failed to read method line: %s

What it means

ParseRawRequest could not read the first line of the raw request via net/textproto: the input was empty, whitespace-only, or the reader hit an error/EOF before any line. Every raw HTTP request must start with a method line like 'GET /path HTTP/1.1'.

Source

Thrown at pkg/input/types/http.go:230

// Clone clones the response
func (hr *HttpResponse) Clone() *HttpResponse {
	return &HttpResponse{
		StatusCode: hr.StatusCode,
		Headers:    hr.Headers.Clone(),
		Body:       hr.Body,
		Raw:        hr.Raw,
	}
}

// ParseRawRequest parses a raw request from a string
// and returns the request and response object
// Note: it currently does not parse response and is meant to be added manually since its a optional field
func ParseRawRequest(raw string) (rr *RequestResponse, err error) {
	protoReader := textproto.NewReader(bufio.NewReader(strings.NewReader(raw)))
	methodLine, err := protoReader.ReadLine()
	if err != nil {
		return nil, fmt.Errorf("failed to read method line: %s", err)
	}
	rr = &RequestResponse{
		Request: &HttpRequest{},
	}
	/// must contain at least 3 parts
	parts := strings.Split(methodLine, " ")
	if len(parts) < 3 {
		return nil, fmt.Errorf("invalid method line: %s", methodLine)
	}
	method := parts[0]
	rr.Request.Method = method

	// the request target is normally an origin-form path, but proxy captures and
	// .http files use the absolute form, which already carries the authority
	var urlx *urlutil.URL
	target := parts[1]
	if stringsutil.HasPrefixAnyI(target, urlutil.HTTP+urlutil.SchemeSeparator, urlutil.HTTPS+urlutil.SchemeSeparator) {
		// urlutil.ParseAbsoluteURL only accepts lowercase schemes; preserve the

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Ensure the raw string begins with a method line: 'GET / HTTP/1.1'
  2. Trim leading whitespace/newlines before parsing if the source tends to inject them
  3. Check the template's raw block indentation in YAML (block scalar content must be indented consistently)

Example fix

# before
raw: |
  Host: example.com

# after
raw: |
  GET / HTTP/1.1
  Host: example.com
Defensive patterns

Strategy: validation

Validate before calling

func hasMethodLine(raw string) bool {
    trimmed := strings.TrimLeft(raw, " \t\r\n")
    return trimmed != "" && !strings.HasPrefix(trimmed, "\n")
}

if !hasMethodLine(raw) { /* reject/repair input before ParseRawRequest */ }

Try / catch

On 'failed to read method line', treat the input as empty/garbage and skip the entry; do not retry with the same bytes.

Prevention

When it happens

Trigger: Calling ParseRawRequest with an empty string, a string of blank lines, or a document whose first line is missing (e.g. starting directly with 'Host: ...').

Common situations: Templates with raw requests where the YAML block scalar is empty; trailing/leading newlines making the first ReadLine blank is tolerated only if a line exists — fully empty input is not; copy-paste losing the first line.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/9d755d7b9bcdf63e. Report an issue: GitHub.