public override async Task ProcessAsync() { // HTTP URI. var url = "http://www.kingcean.net:8080/test/path?a=123&b=hello#nothing/all"; var uri = HttpUri.Parse(url); ConsoleLine.WriteLine(((Uri)uri).ToString()); ConsoleLine.WriteLine(); // Query data. var query = "{ str: \"abcdefg\", b: true, \"name\": \"hijklmn\", // abcd: efg\n \"value\": \"012345\", \"num\": 67, null: undefined, \"props\": { \"x\": \"o\\tp\\tq\", \"y\": [ 8, 9, { \"z\": \"rst\" } ] } }"; var q = QueryData.Parse(query); ConsoleLine.WriteLine(q.ToString()); ConsoleLine.WriteLine(); // JSON HTTP web client. url = "https://github.com/compositejs/datasense/raw/master/package.json"; var webClient = new JsonHttpClient <NameAndDescription>(); var resp = await webClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url)); ConsoleLine.WriteLine(resp.Name); resp = await webClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url)); ConsoleLine.WriteLine(resp.Name); //"{ \"access_token\": \"abc\", \"token_type\": \"Bearer\" }" }
public async Task Does_send_version_using_JsonHttpClient() { var client = new JsonHttpClient(Config.AbsoluteBaseUri); var response = client.Send(new RequestWithVersion { Version = 1 }); Assert.That(response.Version, Is.EqualTo(1)); response = await client.SendAsync(new RequestWithVersion { Version = 1 }); Assert.That(response.Version, Is.EqualTo(1)); client.Version = 1; response = client.Send(new RequestWithVersion()); Assert.That(response.Version, Is.EqualTo(1)); response = await client.SendAsync(new RequestWithVersion()); Assert.That(response.Version, Is.EqualTo(1)); }