Skip to content

Seemingly unnecessary network request to api.nuget.org #4

Description

@j-brooke

Based on the v1.1.0 code, it looks like Rest.Request is making a network call to api.nuget.org prior to every call to the SMSGlobal REST service. I believe this is unnecessary and wasteful.

The purpose seems to be obtaining the latest version of the package to put in the User-Agent header. It seems to me like it would be more valuable to include the currently running package version.

Suggestions to fix:

  1. If possible, eliminate the call to api.nuget.org, and use the current assembly's version. (For example, using typeof(Client).Assembly.GetName().Version.)
  2. If the Nuget call is necessary for some reason, call it once and cache the result in a singleton, or similar.
  3. If the Nuget call is necessary as part of every call, as it's coded now, add comments to explain why.

Also please note that the HttpClient instantiated on line 375 (as of tag 1.1.0) is not properly disposed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions