-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
bugfix#2036 Websocket connections ignore userAgent setting #2151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cooliscool,
thanks for your contribution! 🎉
Can you also add a small test for asserting the expected logic with the header assigned, please?
js/modules/k6/ws/ws.go
Outdated
header := make(http.Header) | ||
tags := state.CloneTags() | ||
|
||
header.Set("User-Agent", state.Options.UserAgent.String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this before CloneTags
, please? I would prefer to not have it in the middle between initialization and assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.! Working on that.
Codecov Report
@@ Coverage Diff @@
## master #2151 +/- ##
==========================================
+ Coverage 72.71% 72.73% +0.01%
==========================================
Files 184 184
Lines 14571 14577 +6
==========================================
+ Hits 10596 10603 +7
+ Misses 3333 3331 -2
- Partials 642 643 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I would prefer we have a test(or to expand one) to actually check that it works so we don't break it later
Explanation for the changes made:I couldn't find a way to retrieve headers of a websocket request that got fired, from within JS environment. ( the actual JS WebSockets API doesn't even have an option to set additional headers. refer this stackoverflow question ) Also kindly let me know if there's a better way to implement this test. I will be happy to make it better. |
I can't figure out why lint is breaking with the message here:
|
@cooliscool that is because you are adding a test and the linter is now noticing it, while it's not going to complain about old stuff as otherwise it will be complaining constantly :(. We do in general fix linter errors when they start bubbling up, but I think this might be a bit too much. On the other hand given that I prefer for you to have a custom handler you can just as well move the whole new test in a new Test function instead of creating a subtest for it as well, and add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from moving the changes from httpmultibin to the test that uses them I have no other requests and I think after that we can merge this 🎉
Thanks a lot for all the work 🙇
… modifications to httpmultibin
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot for all the work 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and I have tiny suggestions.
…re error logging, minor refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I have some minor suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx!
I'd like to thank you all for the quick coordination, code review and suggestions. It was a great deal of learning for me. |
For fixing the Bug #2036
Changes I have made:
Initializing
header
variable beforehand to apply the default User-Agent string (example - "k6/0.27.0 (https://k6.io/)") , OR to apply the User-Agent supplied throughOptions
if it exists.