-
Notifications
You must be signed in to change notification settings - Fork 638
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
DYN-2239 Set the UserAgent for HttpWebRequest #11293
DYN-2239 Set the UserAgent for HttpWebRequest #11293
Conversation
@@ -28,6 +28,9 @@ public static string WebRequestByUrl(string url) | |||
// Initialize the WebRequest. | |||
var myRequest = System.Net.WebRequest.Create(uriResult); | |||
|
|||
if (myRequest is System.Net.HttpWebRequest httpRequest) | |||
httpRequest.UserAgent = "Dynamo"; |
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.
Could you add a comment describing why this is needed?
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.
Addressed in 190a1e7
{ | ||
string url = "https://api.github.com/repos/DynamoDS/Dynamo/issues?page=0&state=closed&per_page=10"; | ||
string result = Web.WebRequestByUrl(url); | ||
Assert.IsNotNullOrEmpty(result); |
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.
Please consider replacing the first test in this file, since this is a better version of it.
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.
Please consider replacing the first test in this file, since this is a better version of it.
@mmisol It looks like the GitHub API has a rate limit of 60 requests per hour per originating IP for unauthenticated
requests (https://developer.github.com/v3/#rate-limiting). If this is exceeded then the test will likely fail due to a 403
response. I'm not familiar with how your test infrastructure is setup so is this likely to cause an issue?
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.
I've addressed this in commit 190a1e7. Removed the WebRequest_ValidArgs
test and revised the GitHub API request to /rate_limit
as requests to this endpoint do not count against your API rate limits.
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 @StudioLE . This looks good to me
* Set the UserAgent for HttpWebRequest * Added WebRequest_GitHubAPI test * Replaced WebRequest_ValidArgs test. Added comment. Revised GitHub API endpoint.
Purpose
JIRA: DYN-2239
Set the
UserAgent
forHTTPWebRequest
which is required by some APIs including GitHub: https://developer.github.com/v3/#user-agent-requiredBehaviour before:

Behaviour after:

Declarations
Check these if you believe they are true
*.resx
filesReviewers
@mjkkirschner @QilongTang @mmisol
FYIs
@Amoursol