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

Why set a UA if one is already supplied #77

Merged
merged 1 commit into from
Jun 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func parseRequestHeader(c *Client, r *Request) error {

if IsStringEmpty(hdr.Get(hdrUserAgentKey)) {
hdr.Set(hdrUserAgentKey, fmt.Sprintf(hdrUserAgentValue, Version))
} else {
hdr.Set("X-"+hdrUserAgentKey, fmt.Sprintf(hdrUserAgentValue, Version))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Robbilie Thank you for the PR. I have read your explanation and understood.

Instead removing, please change to following:

else {
    hdr.Add(hdrUserAgentKey, fmt.Sprintf(hdrUserAgentValue, Version))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that do? Append to the UA? If so I would also advice against this since it leaks information about the client/version (just like you shouldnt expose your webservers or os version on publicly visible status pages).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it appends to it. For server I agree, we shouldn't expose it. But server should know about the client details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont want to have that part included in my UA and i would leave that option to the user to include it. If you want to give the user the option, feel free to add a config flag to enable the appending to the UA, I wont and I cant since i am not a go programmer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I will merge this PR. Thank you for your time. Yes, if user want they can add it.

}

if IsStringEmpty(hdr.Get(hdrAcceptKey)) && !IsStringEmpty(hdr.Get(hdrContentTypeKey)) {
Expand Down