WatsonWebserver icon indicating copy to clipboard operation
WatsonWebserver copied to clipboard

Watson.Lite : C# web-clients not working out of the box with the server.

Open GitHubProUser67 opened this issue 1 year ago • 2 comments
trafficstars

In Watson.Lite, using a stock configured C# downloader as this function does:

image

Will always return a internal server error on the server:

image

GitHubProUser67 avatar Jan 31 '24 20:01 GitHubProUser67

What are you passing in for ip, port, and command?

jchristn avatar Jan 31 '24 21:01 jchristn

So, the system is this.

I pass in the server ip, port 10076, and the command which is a CRUD command.

BUT, I managed to fix the bug, if fact, server needs to be able to attribute default values for the method and content type:

image

Ideally it should default to GET / text/plain.

GitHubProUser67 avatar Feb 06 '24 17:02 GitHubProUser67

Sorry for the delay here, I can't reproduce this using the Test.Default project and v6.1.9.

Your first example:

        public static void Main(string[] args)
        {
            HttpResponseMessage resp = new HttpClient().GetAsync("http://localhost:8080/").Result;
            Console.WriteLine(SerializationHelper.SerializeJson(resp, true));
        }

Returns:

C:\Code\Misc\Sandbox\sandbox\bin\Debug\net8.0>sandbox
{
  "Version": "1.1",
  "Content": {
    "Headers": [
      {
        "Key": "Content-Type",
        "Value": [
          "text/plain"
        ]
      },
      {
        "Key": "Content-Length",
        "Value": [
          "13"
        ]
      }
    ]
  },
  "StatusCode": "OK",
  "ReasonPhrase": "OK",
  "Headers": [
    {
      "Key": "Date",
      "Value": [
        "Sun, 30 Jun 2024 18:32:57 GMT"
      ]
    },
    {
      "Key": "Connection",
      "Value": [
        "close"
      ]
    },
    {
      "Key": "Access-Control-Allow-Origin",
      "Value": [
        "*"
      ]
    },
    {
      "Key": "Access-Control-Allow-Methods",
      "Value": [
        "OPTIONS, HEAD, GET, PUT, POST, DELETE, PATCH"
      ]
    },
    {
      "Key": "Access-Control-Allow-Headers",
      "Value": [
        "*"
      ]
    },
    {
      "Key": "Access-Control-Expose-Headers",
      "Value": [
        ""
      ]
    },
    {
      "Key": "Accept",
      "Value": [
        "*/*"
      ]
    },
    {
      "Key": "Accept-Language",
      "Value": [
        "en-US, en"
      ]
    },
    {
      "Key": "Accept-Charset",
      "Value": [
        "ISO-8859-1, utf-8"
      ]
    },
    {
      "Key": "Cache-Control",
      "Value": [
        "no-cache"
      ]
    },
    {
      "Key": "Host",
      "Value": [
        "localhost:8080"
      ]
    }
  ],
  "TrailingHeaders": [],
  "RequestMessage": {
    "Version": "1.1",
    "VersionPolicy": "RequestVersionOrLower",
    "Method": {
      "Method": "GET"
    },
    "RequestUri": "http://localhost:8080/",
    "Headers": [],
    "Properties": {},
    "Options": {}
  },
  "IsSuccessStatusCode": true
}

Your second example:

            string resp = new WebClient().DownloadStringTaskAsync("http://localhost:8080/").Result;
            Console.WriteLine(resp);

Returns:

C:\Code\Misc\Sandbox\sandbox\bin\Debug\net8.0>sandbox
Default route

jchristn avatar Jun 30 '24 18:06 jchristn