EasyHTTP - Httpclient

You can make a HttpClient like this.
你可以这样创建一个HttpClient。

1
var http = new HttpClient();

The empty constructor means that you will have to provide a url for each and every call (Get, Post, …)

Or like this

空构造函数意味着您必须为每个调用提供一个URL(Get,Post,…)

或者像这样

1
var http = new HttpClient("http://localhost");

Here we instantiated the client with a baseuri. For all the calls you make with this client the baseuri will be prefixed to your uri.

So this.

在这里,我们使用baseuri实例化客户端。 对于您使用此客户端发出的所有请求,baseuri将以uri为前缀。

如:

1
2
var http = new HttpClient("http://localhost");
var result = http.Get("/trees");

is actually the same as writing.

上面的写法与下面是一样的。

1
2
var http = new HttpClient("http://localhost");
var result = http.Get("http://localhost/trees");

The httpclient object contains the Request and Response object. You can set properties on those objects to control the request and response.

The httpclient also contains the following http verbs which you can use.

httpclient对象包含Request和Response对象。 您可以在这些对象上设置属性以控制请求和响应。

httpclient还包含您可以使用的以下http方法。