Closed ehmo closed 5 years ago
Hi Ehmo,
Thank you for using the library. I would reccomend setting the value to " "
which is technically still blank. You can also use the OnRequest
hook. I am planning on changing the behavior of the request setting functionality in the near future which will address this issue.
Using " "
is not a good solution, as it's visible on the server side. If you are using the library for scrapping, it will cause troubles.
I do believe my original comment stands. You should not force the library on the User-Agent. I understand why are you doing it, but people like it plenty without the need of advertising it over the HTTP and causing developers to jump through hoops to deal with it.
As much as I like Grequests and I truly want more people to find about it, forcing default User-Agent is not the way.
https://github.com/levigross/grequests/blob/fd07961896a93d37e169271bb23ee423c42033d3/request.go#L558
Many platform will change behavior based on the User-Agent. Some of their WAF (web application firewall) will try to single out requests originating from the same IP, User-Agent, etc. There are situation where an empty User-Agent needs to be sent, literally
User-Agent:
and Grequests is preventing that from happening.So I would suggest two solutions.
1) Create custom struct that can be set to empty, e.g.
and if
Valid
istrue
then use theString
provided in the struct.2) Remove the check.