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

Issues when passing in multiple values to the OPT_HTTPHEADER #57

Closed
ikandaswamy opened this issue Mar 15, 2017 · 2 comments
Closed

Issues when passing in multiple values to the OPT_HTTPHEADER #57

ikandaswamy opened this issue Mar 15, 2017 · 2 comments

Comments

@ikandaswamy
Copy link

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
Copy link
Author

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
Copy link
Owner

andelf commented Mar 16, 2017

maybe we can hold the reference to the list?

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

2 participants