Package org.microproxy
Class ProtocolPolicy.Builder
java.lang.Object
org.microproxy.ProtocolPolicy.Builder
- Direct Known Subclasses:
Http1PolicyBuilder
- Enclosing class:
ProtocolPolicy
Builds a
ProtocolPolicy. Setters overwrite what an earlier call (or preset(org.microproxy.ProtocolPolicy))
set; fields never set are left to what applies below the policy.-
Method Summary
Modifier and TypeMethodDescriptionbuild()The policy set so far.filterConnectAnswer(boolean filter) preset(ProtocolPolicy preset) Sets every field thatpresetsets (such asProtocolPolicy.littleProxy()), overwriting what was set before; setters called after it overwrite it in turn.proxyProtocolDestination(ProxyProtocolDestination destination) requestHeadTimeout(Duration timeout) resolveBeforeProxyToServerRequest(boolean resolveFirst) servePlainHttpAfterConnect(boolean serve) Sets a field by its configuration name, as the properties file and the command line name them:preset(ProtocolPolicy.preset(String)),resolve_before_proxy_to_server_request,filter_connect_answer,serve_plain_http_after_connect,proxy_protocol_destination(local_addressorserver_address),tls_retry_without_sniandgenerated_responses(GeneratedResponses.parse(java.lang.String)),mitm_server_handshake(MitmServerHandshake.parse(java.lang.String)),request_head_timeout(milliseconds), and for HTTP/1allow_chunked_length.tlsRetryWithoutSni(boolean retry)
-
Method Details
-
preset
Sets every field thatpresetsets (such asProtocolPolicy.littleProxy()), overwriting what was set before; setters called after it overwrite it in turn. A builder for other protocols than HTTP/1 leaves the HTTP/1-only fields alone.- Parameters:
preset- the policy whose fields to copy- Returns:
- this builder
-
resolveBeforeProxyToServerRequest
- Parameters:
resolveFirst- whether the server is resolved beforeproxyToServerRequest- Returns:
- this builder
-
filterConnectAnswer
- Parameters:
filter- whether theCONNECT's200goes through response filters- Returns:
- this builder
-
servePlainHttpAfterConnect
- Parameters:
serve- whether plain HTTP after aCONNECTis served as HTTP- Returns:
- this builder
-
proxyProtocolDestination
- Parameters:
destination- the destination a sent PROXY header names- Returns:
- this builder
-
tlsRetryWithoutSni
- Parameters:
retry- whether to retry without SNI after anunrecognized_namealert- Returns:
- this builder
-
requestHeadTimeout
- Parameters:
timeout- the maximum time for an HTTP/1 request head; zero disables the deadline- Returns:
- this builder
-
generatedResponses
- Parameters:
value- howproxyToClientResponsetreats generated responses- Returns:
- this builder
-
mitmServerHandshake
- Parameters:
value- when the server's handshake runs- Returns:
- this builder
-
set
Sets a field by its configuration name, as the properties file and the command line name them:preset(ProtocolPolicy.preset(String)),resolve_before_proxy_to_server_request,filter_connect_answer,serve_plain_http_after_connect,proxy_protocol_destination(local_addressorserver_address),tls_retry_without_sniandgenerated_responses(GeneratedResponses.parse(java.lang.String)),mitm_server_handshake(MitmServerHandshake.parse(java.lang.String)),request_head_timeout(milliseconds), and for HTTP/1allow_chunked_length. Booleans aretrueorfalse.- Parameters:
name- the field's name (-may stand for_)value- its value- Returns:
- this builder
- Throws:
IllegalArgumentException- for an unknown field (or one of another protocol), or a value the field does not take
-
build
The policy set so far.- Returns:
- the policy
-