What is SchemeRegistry in apache and When it shoul

2020-06-23 07:20发布

问题:

Apache HTTPClient contains SchemeRegistry class (org.apache.http.conn.scheme.SchemeRegistry)

  • What is Scheme Registry?
  • When can it be used?

What impact does it make if i use scheme registry like below

SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme(WEBSERVICE_URI_SCHEME, 80 ,PlainSocketFactory.getSocketFactory()));
PoolingClientConnectionManager wsConnManager = new PoolingClientConnectionManager (registry);

回答1:

What is Scheme Registry?

Protocol scheme registry maintains a map of connection socket factories per distinct protocol scheme. For instance, HTTPS scheme requires that connections be secured with TLS/SSL. One may also want to customize the way sockets for HTTP and HTTPS schemes are created and initialized by registering a custom socket factory for those schemes.

What impact does it make if i use scheme registry like below

You end up with a custom protocol scheme (say, MYHTTP).

Whenever you execute a request using this scheme (say, myhttp://somehost/someservice/) your custom socket factory will be used to create and initialize outgoing connections to the target server.