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

Can't set User-Agent #157

Open
niuzhenyong opened this issue Jun 3, 2019 · 7 comments
Open

Can't set User-Agent #157

niuzhenyong opened this issue Jun 3, 2019 · 7 comments

Comments

@niuzhenyong
Copy link

I can`t set User-Agent with -H.

@lupguo
Copy link

lupguo commented Sep 3, 2019

UA is appended with hey/0.0.1 version information regardless of whether the UA header is set

This is a BUG that always gets an empty ua string through ua := req.UserAgent()

// const heyUA
heyUA        = "hey/0.0.1"
...
// new request object
req, err := http.NewRequest(method, url, nil)
...
// hey set useragent
...
ua := req.UserAgent()
if ua == "" {
    ua = heyUA
} else {
    ua += " " + heyUA
}
header.Set("User-Agent", ua)

spk added a commit to spk/hey that referenced this issue May 30, 2020
on command line the option -H "User-Agent: CustomUserAgent"
is ignored and default user agent is always used
First check if its defined then fallback to default

ref rakyll#87
fix rakyll#157
@Directory
Copy link

wondering whats the status of this. because its still a problem and it doesnt seem like a really hard problem to solve

@pavelzagalsky-paloalto
Copy link

Still happens on the latest version on Brew..

@Directory
Copy link

glad to see that 1 year later nothing has changed -_-

@FrenchBen
Copy link

Fixed with #87

@Dante-dan
Copy link

Maybe, @rakyll should publish a release version. 😢

@lindsey-em
Copy link

Seeing as how it's been two years I don't know when a release version will be pushed so here's what I did:

Uninstall your package release then run the following commands:

export GOPATH=$HOME/gocode
export PATH=$PATH:$GOPATH/bin
go get github.com/rakyll/hey

I don't think it fully works though so don't get your hopes up. I ran this:

hey -n 20 -c 1 -U "test 1 2 3" -h2 https://website.etc/

and this was my UA in my logs:

test 1 2 3 hey/0.0.1

It seems to append the original UA header right after. Let me see if I can fix it, but I've literally never touched Go before

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

Successfully merging a pull request may close this issue.

7 participants