Open CsVeryLoveXieWenLi opened 5 days ago
不应修改? The fields of a Client should not be changed while it is in use.
不应修改? The fields of a Client should not be changed while it is in use.
When a Client
instance makes its first request to a domain, a HostClient
instance is created for that domain, and the initial information for the HostClient
instance is taken from the Client
's configuration. Subsequent requests to the same domain will use the cached HostClient
instance, and the Client
's configuration will not be read again. If you want to update the configuration of the existing Client
, you need to create a new Client
instance. This is how it currently works.
Perhaps a method could be added to Client
to clear all cached HostClient
instances. However, in that case, reusing the Client
wouldn’t have much purpose. You could also use HostClient
directly, but it doesn’t support cross-domain requests or protocol redirection.
Perhaps a method could be added to
Client
to clear all cachedHostClient
instances. However, in that case, reusing theClient
wouldn’t have much purpose. You could also useHostClient
directly, but it doesn’t support cross-domain requests or protocol redirection.
Thank you very much for your answer.
HostClient
的API与Client
的API不是没什么区别吗?难道HostClient
实例允许更改属性?
Isn’t there any difference between the API of HostClient
and that of Client
? Does the HostClient
instance allow changing properties?
Sorry, I don't speak English. So the English is all machine translated.
1. 源代码 || Source Code
我尝试复用
*fasthttp.Client
,而且使用代理。 I tried to reuse*fasthttp.Client
and use a proxy.预想的情况是代理URL是错误的,所以进行请求肯定会出现错误。 The expected situation is that the proxy URL is wrong, so the request will definitely fail.
2. 结果 || Result
确实如此,代理URL是错误的。可是第二次请求设置了
2222
代理。然而,从错误输出来看,第二次请求并没有使用。 Indeed, the proxy URL is wrong. But the second request sets the2222
proxy. However, from the error output, the second request does not use it.我尝试了另一种方式,第一次请求不设置代理,也就是
fasthttp.Client
初始化时。但是,第二次请求仍然不会使用2222
代理。 I tried another way, not setting the proxy for the first request, which is whenfasthttp.Client
is initialized. However, the second request still does not use the2222
proxy.3. 疑问 || Question
难道无法重新设置Dial的值吗,只有在初始化时才可以设置。 Is it not possible to reset the value of Dial? It can only be set during initialization.
我该如何重用
*fasthttp.Client
,并重新设置代理? How can I reuse*fasthttp.Client
and re-set the proxy?