Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求curl返回的各项时间为 0 #60

Closed
oslet opened this issue Aug 18, 2017 · 1 comment
Closed

请求curl返回的各项时间为 0 #60

oslet opened this issue Aug 18, 2017 · 1 comment

Comments

@oslet
Copy link

oslet commented Aug 18, 2017

环境: ubuntu 16.04 x86_64
package main

import (
curl "github.com/andelf/go-curl"
"fmt"
)

func main() {
	easy := curl.EasyInit()
	defer easy.Cleanup()
	if easy != nil {
		easy.Setopt(curl.OPT_URL, "http://www.oslet.net/")
		fmt.Println(easy.Getinfo(curl.INFO_RESPONSE_CODE))
		fmt.Println(easy.Getinfo(curl.INFO_TOTAL_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_APPCONNECT_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_STARTTRANSFER_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_REDIRECT_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_NAMELOOKUP_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_PRETRANSFER_TIME))
		fmt.Println(easy.Getinfo(curl.INFO_CONNECT_TIME))
		
		ver := curl.VersionInfo(curl.VERSION_NOW)
		fmt.Printf("VersionInfo: Age: %d, Version:%s, Host:%s, Features:%d, SslVer: %s, LibzV: %s, ssh: %s\n",
			ver.Age, ver.Version, ver.Host, ver.Features, ver.SslVersion, ver.LibzVersion, ver.LibsshVersion)
	}
}

返回如下数据

0 <nil>
0 <nil>
0 <nil>
0 <nil>
0 <nil>
0 <nil>
0 <nil>
0 <nil>
VersionInfo: Age: 3, Version:7.47.0, Host:x86_64-pc-linux-gnu, Features:968605, SslVer: OpenSSL/1.0.2g, LibzV: 1.2.8, ssh: 
@oslet
Copy link
Author

oslet commented Aug 21, 2017

问题已解决,代码中少了 easy.Perform().

@oslet oslet closed this as completed Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant