Add json content-type for empty requests (fix net/http warning in strict mode)#5615
Add json content-type for empty requests (fix net/http warning in strict mode)#5615kolen wants to merge 1 commit intoSeleniumHQ:masterfrom
Conversation
When doing empty requests (for example for element click), Content-Type header is not set. This causes Net::HTTP warning to show: net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded This sets application/json content-type for such requests (empty requests has empty json object in body).
|
#5659 is alternative solution to the same root problem. In that PR, the issue is resolved by doing explicitly what net-http has been doing implicitly all along, which is to supply the default content type of |
|
@JasonLunn Yes, I think |
|
Thank you for the issue report and PR addressing the problem. I've decided to push a fix by myself so that it complies to JSON Wire Protocol specification of payload. This also makes Ruby bindings behave similarly to Python and Java ones. |
When doing empty requests (for example for element click),
Content-Typeheader is not set. This causesNet::HTTPto issue warning in$VERBOSEmode (-w):This warning shows for each action (click, etc), so there are lots of these warnings in output when running tests.
This pull request adds
Content-Type: application/jsonto such requests too (they has{}body so I guess it's empty json "object")Example script that shows this warning:
I didn't add test for warning, only added check for header being added to request.
warnis not easily stubbable, common way to catch warnings is to redirect stderr toStringIOwhich is too hacky I think.Xin the preceding checkbox, I verify that I have signed the Contributor License Agreement