-
Notifications
You must be signed in to change notification settings - Fork 15
Add a useragent header when fetching data + print response if not JSON #59
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
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.
overall seems ok.
Minimising the use of defaults would be great.
@AkshataDM should be able to provide a deeper review
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.
Overall, this looks great - just make the UA configurable, fix the fmt error, and we can merge.
This commit introduces two fixes/QoL changes. First off, it adds a useragent to every request sent by this tool. This is required iff the remote server rejects requests without any specific useragent being set (an example for this is Wikimedia Toolforge, which will drop all HTTP requests without a User-Agent header See: https://wikitech.wikimedia.org/wiki/Help:Toolforge/Banned#Banned_user_agents_and_IP_addresses Additionally the second change introduced prints the body of the response into stderr iff the tool encounters a error in parsing the JSON data into JWKS sets. This is particularly useful because it (~~allowed me to debug the error above~~) will help folks figure out exactly what data got sent back from the server and why the tool might not be able to validate the keys.
|
Amazing - thanks for your contribution @sohomdatta1! If this doesn't auto-deploy, I will cut a release early next week. |
Major change since last release: Add a useragent header when fetching data + print response if not JSON (#59)
Major change since last release: Add a useragent header when fetching data + print response if not JSON (#59)
Major change since last release: Add a useragent header when fetching data + print response if not JSON (#59)
Major change since last release: Add a useragent header when fetching data + print response if not JSON (#59)
Hi hi,
So, background, I was implementing this protocol on https://github.com/sohomdatta1/link-dispenser (which is a webservice hosted on Wikimedia's community-run Toolforge servers that checks if the external references of/on a page are still web accessible). After implementing the protocol, I was testing the server to make sure I had implemented the directory correctly, and while testing that, I found two small QoL fixes that would be nice to have in this tool! I know the contributing guidelines ask me to create issues, but I decided to open a PR directly since the fixes are relatively minor :)
Basically, this commit introduces two fixes/QoL changes. First off, it adds a useragent to every request sent by this tool. This is required iff the remote server rejects requests without any specific useragent being set (an example for this is Wikimedia Toolforge, which will drop all HTTP requests without a User-Agent header
See: https://wikitech.wikimedia.org/wiki/Help:Toolforge/Banned#Banned_user_agents_and_IP_addresses
Additionally, the second change introduced prints the body of the response into stderr iff the tool encounters an error in parsing the JSON data into JWKS sets. This is particularly useful because it (
allowed me to debug the error above) will help folks figure out exactly what data got sent back from the server and why the tool might not be able to validate the keys.Hope y'all have a nice day!