andelf / go-curl

golang curl(libcurl) binding.
Apache License 2.0
478 stars 129 forks source link

Issues when passing in multiple values to the OPT_HTTPHEADER #57

Closed ikandaswamy closed 7 years ago

ikandaswamy commented 7 years ago

When i set the following and then execute, I get an error saying the page doesn't exist. But when i do the same using curl it works fine.

myCurl.Setopt(curl.OPT_HTTPHEADER, []string{"User-Agent: ikandaswamy", "X-Temp-Header : cb/123"})

The corresponding curl query is curl -H "User-Agent:ikandaswamy" -H "X-N1QL-U: abc" https://api.github.com/users/ikandaswamy/repos

Is there something I'm doing incorrectly ?

Thanks Isha

ikandaswamy commented 7 years ago

Found the solution. slist1 := []string{} slist1 = append(slist1, "X-Temp-Header: "+util.VERSION) for _, head := range header { // Append to the list of Header fields slist1 = append(slist1, head) } myCurl.Setopt(curl.OPT_HTTPHEADER, slist1)

-> This works. We cannot pass in a [] of string directly (as described in the issue), because that throws an error.

Thanks Isha

andelf commented 7 years ago

maybe we can hold the reference to the list?