Skip to content

Commit

Permalink
TimeOut expects a TimeSpan Object as value
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-v-singh committed May 24, 2024
1 parent cd18aae commit 123e2d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions codegens/csharp-restsharp/lib/restsharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function makeOptionsSnippet (urlOrigin, options, indentString, headers) {
});
}
if (options.requestTimeout) {
snippet += `${indentString}Timeout = ${options.requestTimeout},\n`;
snippet += `${indentString}Timeout = new TimeSpan(${options.requestTimeout}),\n`;
}
else {
snippet += `${indentString}Timeout = -1,\n`;
snippet += `${indentString}Timeout = new TimeSpan(-1),\n`;
}
if (!options.followRedirect) {
snippet += `${indentString}FollowRedirects = false,\n`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"result" : "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = -1,\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post/?hardik=\\\"me\\\"\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\nrequest.AddParameter(\"1\", \"a\");\nrequest.AddParameter(\"2\", \"b\");\nrequest.AddParameter(\"\\\"\\\"12\\\"\\\"\", \"\\\"23\\\"\");\nrequest.AddParameter(\"'1\\\"2\\\\\\\"\\\"3'\", \"'1\\\"23\\\"4'\");\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
"result" : "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = new TimeSpan(-1),\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post/?hardik=\\\"me\\\"\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\nrequest.AddParameter(\"1\", \"a\");\nrequest.AddParameter(\"2\", \"b\");\nrequest.AddParameter(\"\\\"\\\"12\\\"\\\"\", \"\\\"23\\\"\");\nrequest.AddParameter(\"'1\\\"2\\\\\\\"\\\"3'\", \"'1\\\"23\\\"4'\");\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"result": "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = -1,\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/json\");\nvar body = @\"{\" + \"\\n\" +\n@\" \"\"json\"\": \"\"Test-Test\"\"\" + \"\\n\" +\n@\"}\";\nrequest.AddStringBody(body, DataFormat.Json);\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
"result": "var options = new RestClientOptions(\"https://postman-echo.com\")\n{\n\tTimeout = new TimeSpan(-1),\n};\nvar client = new RestClient(options);\nvar request = new RestRequest(\"/post\", Method.Post);\nrequest.AddHeader(\"Content-Type\", \"application/json\");\nvar body = @\"{\" + \"\\n\" +\n@\" \"\"json\"\": \"\"Test-Test\"\"\" + \"\\n\" +\n@\"}\";\nrequest.AddStringBody(body, DataFormat.Json);\nRestResponse response = await client.ExecuteAsync(request);\nConsole.WriteLine(response.Content);"
}

0 comments on commit 123e2d3

Please sign in to comment.