Skip to content

User-Agent header set incorrectly in case of C# #158

@peterbozso

Description

@peterbozso

Describe the bug
Affected code-generator: csharp-restsharp
The problem is clearly described in this issue of RestSharp: restsharp/RestSharp#787
In a nutshell, the code-generator currently sets the User-Agent like this:

request.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0");

But it's not effective at all, see issue referenced above. The solution is from the same issue as well. The correct way to set it is on the client level, like this:

client.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"

To Reproduce
Generate C# code for a request where the User-Agent header is set, then execute the generated code. Observe that the User-Agent is set to RestSharp x.x.x.x instead of the one in the generated code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions