Package org.apache.catalina.connector
Class Connector
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.connector.Connector
- All Implemented Interfaces:
- MBeanRegistration,- JmxEnabled,- Lifecycle
Implementation of a Coyote connector.
- Author:
- Craig R. McClanahan, Remy Maucherat
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.catalina.LifecycleLifecycle.SingleUse
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AdapterCoyote adapter.protected booleanIf this istruethe '\' character will be permitted as a path delimiter.protected booleanDo we allow TRACE ?protected longDefault timeout for asynchronous requests (ms).protected final StringName of the protocol that was configured.protected booleanThe flag that controls recycling of the facades of the request processing objects.protected booleanThe "enable DNS lookups" flag for this Connector.protected booleanIf this istruethen a call toResponse.getWriter()if no character encoding has been specified will result in subsequent calls toResponse.getCharacterEncoding()returningISO-8859-1and theContent-Typeresponse header will include acharset=ISO-8859-1component.static final Stringprotected intThe maximum number of parameters (GET plus POST) which will be automatically parsed by the container. 10000 by default.protected intMaximum size of a POST which will be automatically parsed by the container. 2 MiB by default.protected intMaximum size of a POST which will be saved by the container during authentication. 4 KiB by defaultprotected StringComma-separated list of HTTP methods that will be parsed according to POST-style rules for application/x-www-form-urlencoded request bodies.A Set of methods determined byparseBodyMethods.protected final ProtocolHandlerCoyote protocol handler.protected final StringCoyote Protocol handler class name.protected StringThe server name to which we should pretend requests to this Connector were directed.protected intThe server port to which we should pretend requests to this Connector were directed.protected intThe redirect port for non-SSL to SSL redirects.protected StringThe request scheme that will be set on all requests received through this connector.protected booleanThe secure connection flag that will be set on all requests received through this connector.protected ServiceTheServicewe are associated with (if any).protected static final StringManagerThe string manager for this package.protected booleanURI encoding as body.protected booleanFlag to use IP-based virtual hosting.protected booleanIs generation of X-Powered-By response header enabled/disabled?Fields inherited from interface org.apache.catalina.LifecycleAFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
- 
Constructor SummaryConstructorsConstructorDescriptionDefaults to using HTTP/1.1 NIO implementation.Connector(ProtocolHandler protocolHandler) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddSslHostConfig(SSLHostConfig sslHostConfig) voidaddUpgradeProtocol(UpgradeProtocol upgradeProtocol) protected StringCreate (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.protected voidSub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.booleanbooleanlongbooleanprotected StringMethod implemented by sub-classes to identify the domain in which MBeans should be registered.booleanbooleanintintintintintprotected StringAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.intgetPort()intintgetProperty(String name) Return a property from the protocol handler.intintintbooleanbooleanbooleanbooleanTest if IP-based virtual hosting is enabled.booleanIndicates whether the generation of an X-Powered-By response header for Servlet-generated responses is enabled or disabled for this Connector.protected voidSub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.protected booleanisParseBodyMethod(String method) voidpause()Pause the connector.voidresume()Resume the connector.voidsetAllowBackslash(boolean allowBackslash) Set the allowBackslash flag.voidsetAllowTrace(boolean allowTrace) Set the allowTrace flag, to disable or enable the TRACE HTTP method.voidsetAsyncTimeout(long asyncTimeout) Set the default timeout for async requests.voidsetDiscardFacades(boolean discardFacades) Set the recycling strategy for the object facades.voidsetEnableLookups(boolean enableLookups) Set the "enable DNS lookups" flag.voidsetEncodedSolidusHandling(String encodedSolidusHandling) voidsetEnforceEncodingInGetWriter(boolean enforceEncodingInGetWriter) Set the enforceEncodingInGetWriter flag.voidsetMaxCookieCount(int maxCookieCount) voidsetMaxParameterCount(int maxParameterCount) Set the maximum number of parameters (GET plus POST) that will be automatically parsed by the container.voidsetMaxPostSize(int maxPostSize) Set the maximum size of a POST which will be automatically parsed by the container.voidsetMaxSavePostSize(int maxSavePostSize) Set the maximum size of a POST which will be saved by the container during authentication.voidsetParseBodyMethods(String methods) Set list of HTTP methods which should allow body parameter parsing.voidsetPort(int port) Set the port number on which we listen for requests.voidsetPortOffset(int portOffset) booleansetProperty(String name, String value) Set a property on the protocol handler.voidsetProxyName(String proxyName) Set the proxy server name for this Connector.voidsetProxyPort(int proxyPort) Set the proxy server port for this Connector.voidsetRedirectPort(int redirectPort) Set the redirect port number.voidsetRejectSuspiciousURIs(boolean rejectSuspiciousURIs) voidSet the scheme that will be assigned to requests received through this connector.voidsetSecure(boolean secure) Set the secure connection flag that will be assigned to requests received through this connector.voidsetService(Service service) Set theServicewith which we are associated (if any).voidsetURIEncoding(String URIEncoding) Set the URI encoding to be used for the URI.voidsetUseBodyEncodingForURI(boolean useBodyEncodingForURI) Set if the entity body encoding should be used for the URI.voidsetUseIPVHosts(boolean useIPVHosts) Enable the use of IP-based virtual hosting.voidsetXpoweredBy(boolean xpoweredBy) Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.protected voidBegin processing requests via this Connector.protected voidTerminate processing requests via this Connector.toString()Provide a useful toString() implementation as it may be used when logging Lifecycle errors to identify the component.Methods inherited from class org.apache.catalina.util.LifecycleMBeanBasegetDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisterMethods inherited from class org.apache.catalina.util.LifecycleBaseaddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
- 
Field Details- 
INTERNAL_EXECUTOR_NAME- See Also:
 
- 
serviceTheServicewe are associated with (if any).
- 
allowBackslashprotected boolean allowBackslashIf this istruethe '\' character will be permitted as a path delimiter. If not specified, the default value offalsewill be used.
- 
allowTraceprotected boolean allowTraceDo we allow TRACE ?
- 
asyncTimeoutprotected long asyncTimeoutDefault timeout for asynchronous requests (ms).
- 
enableLookupsprotected boolean enableLookupsThe "enable DNS lookups" flag for this Connector.
- 
enforceEncodingInGetWriterprotected boolean enforceEncodingInGetWriterIf this istruethen a call toResponse.getWriter()if no character encoding has been specified will result in subsequent calls toResponse.getCharacterEncoding()returningISO-8859-1and theContent-Typeresponse header will include acharset=ISO-8859-1component. (SRV.15.2.22.1) If not specified, the default specification compliant value oftruewill be used.
- 
xpoweredByprotected boolean xpoweredByIs generation of X-Powered-By response header enabled/disabled?
- 
proxyNameThe server name to which we should pretend requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the server name included in theHostheader is used.
- 
proxyPortprotected int proxyPortThe server port to which we should pretend requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the port number specified by theportproperty is used.
- 
discardFacadesprotected boolean discardFacadesThe flag that controls recycling of the facades of the request processing objects. If set totruethe object facades will be discarded when the request is recycled. If the security manager is enabled, this setting is ignored and object facades are always discarded.
- 
redirectPortprotected int redirectPortThe redirect port for non-SSL to SSL redirects.
- 
schemeThe request scheme that will be set on all requests received through this connector.
- 
secureprotected boolean secureThe secure connection flag that will be set on all requests received through this connector.
- 
smThe string manager for this package.
- 
maxParameterCountprotected int maxParameterCountThe maximum number of parameters (GET plus POST) which will be automatically parsed by the container. 10000 by default. The default Tomcat server.xml configures a lower default of 1000. A value of less than 0 means no limit.
- 
maxPostSizeprotected int maxPostSizeMaximum size of a POST which will be automatically parsed by the container. 2 MiB by default.
- 
maxSavePostSizeprotected int maxSavePostSizeMaximum size of a POST which will be saved by the container during authentication. 4 KiB by default
- 
parseBodyMethodsComma-separated list of HTTP methods that will be parsed according to POST-style rules for application/x-www-form-urlencoded request bodies.
- 
parseBodyMethodsSetA Set of methods determined byparseBodyMethods.
- 
useIPVHostsprotected boolean useIPVHostsFlag to use IP-based virtual hosting.
- 
protocolHandlerClassNameCoyote Protocol handler class name. SeeConnector()for current default.
- 
configuredProtocolName of the protocol that was configured.
- 
protocolHandlerCoyote protocol handler.
- 
adapterCoyote adapter.
- 
useBodyEncodingForURIprotected boolean useBodyEncodingForURIURI encoding as body.
 
- 
- 
Constructor Details- 
Connectorpublic Connector()Defaults to using HTTP/1.1 NIO implementation.
- 
Connector
- 
Connector
 
- 
- 
Method Details- 
getPropertyReturn a property from the protocol handler.- Parameters:
- name- the property name
- Returns:
- the property value
 
- 
setPropertySet a property on the protocol handler.- Parameters:
- name- the property name
- value- the property value
- Returns:
- trueif the property was successfully set
 
- 
getService- Returns:
- the Servicewith which we are associated (if any).
 
- 
setServiceSet theServicewith which we are associated (if any).- Parameters:
- service- The service that owns this Engine
 
- 
getAllowBackslashpublic boolean getAllowBackslash()- Returns:
- trueif backslash characters are allowed in URLs. Default value is- false.
 
- 
setAllowBackslashpublic void setAllowBackslash(boolean allowBackslash) Set the allowBackslash flag.- Parameters:
- allowBackslash- the new flag value
 
- 
getAllowTracepublic boolean getAllowTrace()- Returns:
- trueif the TRACE method is allowed. Default value is- false.
 
- 
setAllowTracepublic void setAllowTrace(boolean allowTrace) Set the allowTrace flag, to disable or enable the TRACE HTTP method.- Parameters:
- allowTrace- The new allowTrace flag
 
- 
getAsyncTimeoutpublic long getAsyncTimeout()- Returns:
- the default timeout for async requests in ms.
 
- 
setAsyncTimeoutpublic void setAsyncTimeout(long asyncTimeout) Set the default timeout for async requests.- Parameters:
- asyncTimeout- The new timeout in ms.
 
- 
getDiscardFacadespublic boolean getDiscardFacades()- Returns:
- trueif the object facades are discarded, either when the discardFacades value is- trueor when the security manager is enabled.
 
- 
setDiscardFacadespublic void setDiscardFacades(boolean discardFacades) Set the recycling strategy for the object facades.- Parameters:
- discardFacades- the new value of the flag
 
- 
getEnableLookupspublic boolean getEnableLookups()- Returns:
- the "enable DNS lookups" flag.
 
- 
setEnableLookupspublic void setEnableLookups(boolean enableLookups) Set the "enable DNS lookups" flag.- Parameters:
- enableLookups- The new "enable DNS lookups" flag value
 
- 
getEnforceEncodingInGetWriterpublic boolean getEnforceEncodingInGetWriter()- Returns:
- trueif a default character encoding will be set when calling Response.getWriter()
 
- 
setEnforceEncodingInGetWriterpublic void setEnforceEncodingInGetWriter(boolean enforceEncodingInGetWriter) Set the enforceEncodingInGetWriter flag.- Parameters:
- enforceEncodingInGetWriter- the new flag value
 
- 
getMaxCookieCountpublic int getMaxCookieCount()
- 
setMaxCookieCountpublic void setMaxCookieCount(int maxCookieCount) 
- 
getMaxParameterCountpublic int getMaxParameterCount()- Returns:
- the maximum number of parameters (GET plus POST) that will be automatically parsed by the container. A value of less than 0 means no limit.
 
- 
setMaxParameterCountpublic void setMaxParameterCount(int maxParameterCount) Set the maximum number of parameters (GET plus POST) that will be automatically parsed by the container. A value of less than 0 means no limit.- Parameters:
- maxParameterCount- The new setting
 
- 
getMaxPostSizepublic int getMaxPostSize()- Returns:
- the maximum size of a POST which will be automatically parsed by the container.
 
- 
setMaxPostSizepublic void setMaxPostSize(int maxPostSize) Set the maximum size of a POST which will be automatically parsed by the container.- Parameters:
- maxPostSize- The new maximum size in bytes of a POST which will be automatically parsed by the container
 
- 
getMaxSavePostSizepublic int getMaxSavePostSize()- Returns:
- the maximum size of a POST which will be saved by the container during authentication.
 
- 
setMaxSavePostSizepublic void setMaxSavePostSize(int maxSavePostSize) Set the maximum size of a POST which will be saved by the container during authentication.- Parameters:
- maxSavePostSize- The new maximum size in bytes of a POST which will be saved by the container during authentication.
 
- 
getParseBodyMethods- Returns:
- the HTTP methods which will support body parameters parsing
 
- 
setParseBodyMethodsSet list of HTTP methods which should allow body parameter parsing. This defaults toPOST.- Parameters:
- methods- Comma separated list of HTTP method names
 
- 
isParseBodyMethod
- 
getPortpublic int getPort()- Returns:
- the port number on which this connector is configured to listen for requests. The special value of 0 means select a random free port when the socket is bound.
 
- 
setPortpublic void setPort(int port) Set the port number on which we listen for requests.- Parameters:
- port- The new port number
 
- 
getPortOffsetpublic int getPortOffset()
- 
setPortOffsetpublic void setPortOffset(int portOffset) 
- 
getPortWithOffsetpublic int getPortWithOffset()
- 
getLocalPortpublic int getLocalPort()- Returns:
- the port number on which this connector is listening to requests. If the special value for
             getPort()of zero is used then this method will report the actual port bound.
 
- 
getProtocol- Returns:
- the Coyote protocol handler in use.
 
- 
getProtocolHandlerClassName- Returns:
- the class name of the Coyote protocol handler in use.
 
- 
getProtocolHandler- Returns:
- the protocol handler associated with the connector.
 
- 
getProxyName- Returns:
- the proxy server name for this Connector.
 
- 
setProxyNameSet the proxy server name for this Connector.- Parameters:
- proxyName- The new proxy server name
 
- 
getProxyPortpublic int getProxyPort()- Returns:
- the proxy server port for this Connector.
 
- 
setProxyPortpublic void setProxyPort(int proxyPort) Set the proxy server port for this Connector.- Parameters:
- proxyPort- The new proxy server port
 
- 
getRedirectPortpublic int getRedirectPort()- Returns:
- the port number to which a request should be redirected if it comes in on a non-SSL port and is subject to a security constraint with a transport guarantee that requires SSL.
 
- 
setRedirectPortpublic void setRedirectPort(int redirectPort) Set the redirect port number.- Parameters:
- redirectPort- The redirect port number (non-SSL to SSL)
 
- 
getRedirectPortWithOffsetpublic int getRedirectPortWithOffset()
- 
getScheme- Returns:
- the scheme that will be assigned to requests received through this connector. Default value is "http".
 
- 
setSchemeSet the scheme that will be assigned to requests received through this connector.- Parameters:
- scheme- The new scheme
 
- 
getSecurepublic boolean getSecure()- Returns:
- the secure connection flag that will be assigned to requests received through this connector. Default value is "false".
 
- 
setSecurepublic void setSecure(boolean secure) Set the secure connection flag that will be assigned to requests received through this connector.- Parameters:
- secure- The new secure connection flag
 
- 
getURIEncoding- Returns:
- the name of character encoding to be used for the URI using the original case.
 
- 
getURICharset- Returns:
- The Charset to use to convert raw URI bytes (after %nn decoding) to characters. This will never be null
 
- 
setURIEncodingSet the URI encoding to be used for the URI.- Parameters:
- URIEncoding- The new URI character encoding.
 
- 
getUseBodyEncodingForURIpublic boolean getUseBodyEncodingForURI()- Returns:
- the true if the entity body encoding should be used for the URI.
 
- 
setUseBodyEncodingForURIpublic void setUseBodyEncodingForURI(boolean useBodyEncodingForURI) Set if the entity body encoding should be used for the URI.- Parameters:
- useBodyEncodingForURI- The new value for the flag.
 
- 
getXpoweredBypublic boolean getXpoweredBy()Indicates whether the generation of an X-Powered-By response header for Servlet-generated responses is enabled or disabled for this Connector.- Returns:
- trueif generation of X-Powered-By response header is enabled, false otherwise
 
- 
setXpoweredBypublic void setXpoweredBy(boolean xpoweredBy) Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.- Parameters:
- xpoweredBy- true if generation of X-Powered-By response header is to be enabled, false otherwise
 
- 
setUseIPVHostspublic void setUseIPVHosts(boolean useIPVHosts) Enable the use of IP-based virtual hosting.- Parameters:
- useIPVHosts-- trueif Hosts are identified by IP,- falseif Hosts are identified by name.
 
- 
getUseIPVHostspublic boolean getUseIPVHosts()Test if IP-based virtual hosting is enabled.- Returns:
- trueif IP vhosts are enabled
 
- 
getExecutorName
- 
addSslHostConfig
- 
findSslHostConfigs
- 
addUpgradeProtocol
- 
findUpgradeProtocols
- 
getEncodedSolidusHandling
- 
setEncodedSolidusHandling
- 
getEncodedSolidusHandlingInternal
- 
getRejectSuspiciousURIspublic boolean getRejectSuspiciousURIs()
- 
setRejectSuspiciousURIspublic void setRejectSuspiciousURIs(boolean rejectSuspiciousURIs) 
- 
createRequestCreate (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.- Returns:
- a new Servlet request object
 
- 
createResponseCreate (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.- Returns:
- a new Servlet response object
 
- 
createObjectNameKeyProperties
- 
pausepublic void pause()Pause the connector.
- 
resumepublic void resume()Resume the connector.
- 
initInternalDescription copied from class:LifecycleMBeanBaseSub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.- Overrides:
- initInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the initialisation fails
 
- 
startInternalBegin processing requests via this Connector.- Specified by:
- startInternalin class- LifecycleBase
- Throws:
- LifecycleException- if a fatal startup error occurs
 
- 
stopInternalTerminate processing requests via this Connector.- Specified by:
- stopInternalin class- LifecycleBase
- Throws:
- LifecycleException- if a fatal shutdown error occurs
 
- 
destroyInternalDescription copied from class:LifecycleMBeanBaseSub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.- Overrides:
- destroyInternalin class- LifecycleMBeanBase
- Throws:
- LifecycleException- If the destruction fails
 
- 
toStringProvide a useful toString() implementation as it may be used when logging Lifecycle errors to identify the component.
- 
getDomainInternalDescription copied from class:LifecycleMBeanBaseMethod implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
- getDomainInternalin class- LifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
 
- 
getObjectNameKeyPropertiesDescription copied from class:LifecycleMBeanBaseAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
- getObjectNameKeyPropertiesin class- LifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the
          desired ObjectName
 
 
-