public class ProtocolService
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
ProtocolHandler |
removeProtocolHandler(java.lang.String protocol)
Unregisters the given protocol
注销给定协议的给定协议处理程序。 handler for the given
protocol .
|
ProtocolHandler |
setProtocolHandler(java.lang.String protocol, ProtocolHandler handler)
Registers protocol
注册协议处理程序,该处理程序允许处理给定协议的所有URL请求。 handler that allows handling all URL requests for the given
protocol .
|
public ProtocolHandler setProtocolHandler(java.lang.String protocol, ProtocolHandler handler)
handler
that allows handling all URL requests for the given
protocol
. You can intercept all URL requests for the given
protocol
and send your own response data. You can register handlers for standard protocols such as http, https, ftp, etc. as well as for non-standard protocols such as jar, my-protocol, etc.
Note: when protocol handler is registered for the given protocol
, the onBeforeSendHeaders(BeforeSendHeadersParams)
and onHeadersReceived(HeadersReceivedParams)
methods of the NetworkDelegate
will not be called if URL request is handled by the registered protocol handler.
protocol
- a string that represents protocol name (e.g. "http", "ftp", etc.). It's not case-sensitive. The requirements for protocol name are described in RFC 2396 (chapter 3.1). Cannot be empty or
null
.
-代表协议名称的字符串(例如“ http”,“ ftp”等)。它不区分大小写。协议名称的要求在RFC 2396(第3.1章)中进行了描述。不能为空或。
handler
- a protocol handler that will be called to handle URL requests. Cannot be
null
.
-协议处理程序,将被调用以处理URL请求。不可能是 。
ProtocolHandler
instance associated with the given
protocol
or
null
if there is no previously registered protocol handler.
与给定关联的先前注册的实例,或者如果没有先前注册的协议处理程序。
java.lang.IllegalArgumentException
- when
protocol
is empty or
null
.
java.lang.IllegalArgumentException
- when
handler
is
null
.
public ProtocolHandler removeProtocolHandler(java.lang.String protocol)
handler
for the given
protocol
. It does nothing if there is no registered protocol handler.
protocol
- the protocol to unregister.
-取消注册的协议。
null
if there is no protocol handler associated with the given
protocol
.
未注册的协议处理程序,或者没有与给定的协议处理程序关联的协议处理程序。