You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failures shouldn't recommend mocking the "User-Agent" header. #596
If one includes that header in the stub, tests will pass locally. travis et al will fail opaquely because they are (very likely) testing different versions on a different platform.
Instead of blindly pumping out all headers in this helpful error message, I'd like to propose deleting whatever User-Agent is set. I'd be happy to provide a patch if this sounds desirable.
Reacted by bootstraponline, redbar0n, Leonhardt Wille, sknight-msts, Everaldo Gomes and kevin
Thank you @abscondment, and @KelseyDH who asked for the same in #857. Since 3.39.0, the stub that WebMock suggests for an unmatched request leaves User-Agent out, so a stub pasted from it keeps matching after the client is upgraded and on other platforms. The message still shows the request with all its headers, and the other headers stay in the suggestion.
Activity
bblimke commentedon Mar 12, 2016
👍 good idea. Please do submit a pull request.
everaldo commentedon Nov 9, 2018
@abscondment , did you get any solution for that?
everaldo commentedon Nov 9, 2018
I decided to match User-Agent agains a regular expression, as explained here
https://github.com/bblimke/webmock#matching-request-body-and-headers-against-regular-expressions
naufil50 commentedon Aug 1, 2023
I faced similar issue, removed header from stub and it worked fine.
Leave User-Agent out of the suggested stub for an unmatched request
bblimke commentedon Nov 23, 2026
Thank you @abscondment, and @KelseyDH who asked for the same in #857. Since 3.39.0, the stub that WebMock suggests for an unmatched request leaves
User-Agentout, so a stub pasted from it keeps matching after the client is upgraded and on other platforms. The message still shows the request with all its headers, and the other headers stay in the suggestion.