XIU2/CloudflareSpeedTest · warning

[调试] IP: %s, 延迟测速请求创建失败,错误信息: %v, 测速地址: %s

Error message

[调试] IP: %s, 延迟测速请求创建失败,错误信息: %v, 测速地址: %s

What it means

Debug-only branch in task/httping.go:45-51: http.NewRequest(HEAD, URL, nil) failed for the HTTPing latency URL, so this IP is discarded (return 0, 0, ""). NewRequest only errors when the URL string cannot be parsed, so in practice every IP fails identically and the whole HTTPing run returns zero results.

Source

Thrown at task/httping.go:48

	hc := http.Client{
		Timeout: time.Second * 2,
		Transport: &http.Transport{
			DialContext: getDialContext(ip),
			//TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // 跳过证书验证
		},
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return http.ErrUseLastResponse // 阻止重定向
		},
	}
	defer hc.CloseIdleConnections()

	// 先访问一次获得 HTTP 状态码 及 地区码
	var colo string
	{
		request, err := http.NewRequest(http.MethodHead, URL, nil)
		if err != nil {
			if utils.Debug { // 调试模式下,输出更多信息
				utils.Red.Printf("[调试] IP: %s, 延迟测速请求创建失败,错误信息: %v, 测速地址: %s\n", ip.String(), err, URL)
			}
			return 0, 0, ""
		}
		request.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36")
		response, err := hc.Do(request)
		if err != nil {
			if utils.Debug { // 调试模式下,输出更多信息
				utils.Red.Printf("[调试] IP: %s, 延迟测速失败,错误信息: %v, 测速地址: %s\n", ip.String(), err, URL)
			}
			return 0, 0, ""
		}
		defer response.Body.Close()

		//fmt.Println("IP:", ip, "StatusCode:", response.StatusCode, response.Request.URL)
		// 如果未指定的 HTTP 状态码,或指定的状态码不合规,则默认只认为 200、301、302 才算 HTTPing 通过
		if HttpingStatusCode == 0 || HttpingStatusCode < 100 && HttpingStatusCode > 599 {
			if response.StatusCode != 200 && response.StatusCode != 301 && response.StatusCode != 302 {
				if utils.Debug { // 调试模式下,输出更多信息

View on GitHub (pinned to 1da0c025d7)

Solutions

  1. Fix the -url value: include the full scheme and path, e.g. -url https://speed.example.com/50mb.bin.
  2. Verify it parses before the run: parse it with a one-liner or just curl it.
  3. If the URL is correct but you still see these, re-run without -debug to confirm the message is per-IP noise and check error [4] for the real transport failure.

Example fix

# before
./cfst -httping -url speed.example.com/url
# after
./cfst -httping -url https://speed.example.com/url
Defensive patterns

Strategy: validation

Validate before calling

# go: verify once before the run
if _, err := url.Parse(task.URL); err != nil || !strings.Contains(task.URL, "://") {
    log.Fatalf("invalid -url: %q", task.URL)
}
# shell
case "$URL" in https://*|http://*) ;; *) echo "-url needs a scheme"; exit 1;; esac

Type guard

func validTestURL(s string) bool {
	u, err := url.Parse(s)
	return err == nil && (u.Scheme == "http" || u.Scheme == "https") && u.Host != ""
}

Prevention

When it happens

Trigger: Passing -httping together with a -url value that url.Parse rejects: missing scheme (cf.example.com/url), a space or control character in the URL, or an unparseable port like https://host:port/x. Since URL is a global, the same failure repeats for every IP tested.

Common situations: Users switching to -httping and pasting a URL without the https:// prefix; scripts interpolating an empty variable into -url; trailing whitespace or quotes inside the -url argument.

Related errors


AI-assisted analysis of XIU2/CloudflareSpeedTest@1da0c025d7 (2026-08-15). Data as JSON: /api/errors/91709fa9587f68e6. Report an issue: GitHub.