Class Connector

All Implemented Interfaces:
MBeanRegistration, JmxEnabled, Lifecycle

public class Connector extends LifecycleMBeanBase
Implementation of a Coyote connector.
Author:
Craig R. McClanahan, Remy Maucherat
  • Field Details Link icon

    • INTERNAL_EXECUTOR_NAME Link icon

      public static final String INTERNAL_EXECUTOR_NAME
      See Also:
    • service Link icon

      protected Service service
      The Service we are associated with (if any).
    • allowBackslash Link icon

      protected boolean allowBackslash
      If this is true the '\' character will be permitted as a path delimiter. If not specified, the default value of false will be used.
    • allowTrace Link icon

      protected boolean allowTrace
      Do we allow TRACE ?
    • asyncTimeout Link icon

      protected long asyncTimeout
      Default timeout for asynchronous requests (ms).
    • enableLookups Link icon

      protected boolean enableLookups
      The "enable DNS lookups" flag for this Connector.
    • enforceEncodingInGetWriter Link icon

      protected boolean enforceEncodingInGetWriter
      If this is true then a call to Response.getWriter() if no character encoding has been specified will result in subsequent calls to Response.getCharacterEncoding() returning ISO-8859-1 and the Content-Type response header will include a charset=ISO-8859-1 component. (SRV.15.2.22.1) If not specified, the default specification compliant value of true will be used.
    • xpoweredBy Link icon

      protected boolean xpoweredBy
      Is generation of X-Powered-By response header enabled/disabled?
    • proxyName Link icon

      protected String proxyName
      The 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 the Host header is used.
    • proxyPort Link icon

      protected int proxyPort
      The 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 the port property is used.
    • discardFacades Link icon

      protected boolean discardFacades
      The flag that controls recycling of the facades of the request processing objects. If set to true the 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.
    • redirectPort Link icon

      protected int redirectPort
      The redirect port for non-SSL to SSL redirects.
    • scheme Link icon

      protected String scheme
      The request scheme that will be set on all requests received through this connector.
    • secure Link icon

      protected boolean secure
      The secure connection flag that will be set on all requests received through this connector.
    • sm Link icon

      protected static final StringManager sm
      The string manager for this package.
    • maxParameterCount Link icon

      protected int maxParameterCount
      The 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.
    • maxPostSize Link icon

      protected int maxPostSize
      Maximum size of a POST which will be automatically parsed by the container. 2 MiB by default.
    • maxSavePostSize Link icon

      protected int maxSavePostSize
      Maximum size of a POST which will be saved by the container during authentication. 4 KiB by default
    • parseBodyMethods Link icon

      protected String parseBodyMethods
      Comma-separated list of HTTP methods that will be parsed according to POST-style rules for application/x-www-form-urlencoded request bodies.
    • parseBodyMethodsSet Link icon

      protected HashSet<String> parseBodyMethodsSet
      A Set of methods determined by parseBodyMethods.
    • useIPVHosts Link icon

      protected boolean useIPVHosts
      Flag to use IP-based virtual hosting.
    • protocolHandlerClassName Link icon

      protected final String protocolHandlerClassName
      Coyote Protocol handler class name. See Connector() for current default.
    • configuredProtocol Link icon

      protected final String configuredProtocol
      Name of the protocol that was configured.
    • protocolHandler Link icon

      protected final ProtocolHandler protocolHandler
      Coyote protocol handler.
    • adapter Link icon

      protected Adapter adapter
      Coyote adapter.
    • useBodyEncodingForURI Link icon

      protected boolean useBodyEncodingForURI
      URI encoding as body.
  • Constructor Details Link icon

    • Connector Link icon

      public Connector()
      Defaults to using HTTP/1.1 NIO implementation.
    • Connector Link icon

      public Connector(String protocol)
    • Connector Link icon

      public Connector(ProtocolHandler protocolHandler)
  • Method Details Link icon

    • getProperty Link icon

      public Object getProperty(String name)
      Return a property from the protocol handler.
      Parameters:
      name - the property name
      Returns:
      the property value
    • setProperty Link icon

      public boolean setProperty(String name, String value)
      Set a property on the protocol handler.
      Parameters:
      name - the property name
      value - the property value
      Returns:
      true if the property was successfully set
    • getService Link icon

      public Service getService()
      Returns:
      the Service with which we are associated (if any).
    • setService Link icon

      public void setService(Service service)
      Set the Service with which we are associated (if any).
      Parameters:
      service - The service that owns this Engine
    • getAllowBackslash Link icon

      public boolean getAllowBackslash()
      Returns:
      true if backslash characters are allowed in URLs. Default value is false.
    • setAllowBackslash Link icon

      public void setAllowBackslash(boolean allowBackslash)
      Set the allowBackslash flag.
      Parameters:
      allowBackslash - the new flag value
    • getAllowTrace Link icon

      public boolean getAllowTrace()
      Returns:
      true if the TRACE method is allowed. Default value is false.
    • setAllowTrace Link icon

      public void setAllowTrace(boolean allowTrace)
      Set the allowTrace flag, to disable or enable the TRACE HTTP method.
      Parameters:
      allowTrace - The new allowTrace flag
    • getAsyncTimeout Link icon

      public long getAsyncTimeout()
      Returns:
      the default timeout for async requests in ms.
    • setAsyncTimeout Link icon

      public void setAsyncTimeout(long asyncTimeout)
      Set the default timeout for async requests.
      Parameters:
      asyncTimeout - The new timeout in ms.
    • getDiscardFacades Link icon

      public boolean getDiscardFacades()
      Returns:
      true if the object facades are discarded, either when the discardFacades value is true or when the security manager is enabled.
    • setDiscardFacades Link icon

      public void setDiscardFacades(boolean discardFacades)
      Set the recycling strategy for the object facades.
      Parameters:
      discardFacades - the new value of the flag
    • getEnableLookups Link icon

      public boolean getEnableLookups()
      Returns:
      the "enable DNS lookups" flag.
    • setEnableLookups Link icon

      public void setEnableLookups(boolean enableLookups)
      Set the "enable DNS lookups" flag.
      Parameters:
      enableLookups - The new "enable DNS lookups" flag value
    • getEnforceEncodingInGetWriter Link icon

      public boolean getEnforceEncodingInGetWriter()
      Returns:
      true if a default character encoding will be set when calling Response.getWriter()
    • setEnforceEncodingInGetWriter Link icon

      public void setEnforceEncodingInGetWriter(boolean enforceEncodingInGetWriter)
      Set the enforceEncodingInGetWriter flag.
      Parameters:
      enforceEncodingInGetWriter - the new flag value
    • getMaxCookieCount Link icon

      public int getMaxCookieCount()
    • setMaxCookieCount Link icon

      public void setMaxCookieCount(int maxCookieCount)
    • getMaxParameterCount Link icon

      public 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.
    • setMaxParameterCount Link icon

      public 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
    • getMaxPostSize Link icon

      public int getMaxPostSize()
      Returns:
      the maximum size of a POST which will be automatically parsed by the container.
    • setMaxPostSize Link icon

      public 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
    • getMaxSavePostSize Link icon

      public int getMaxSavePostSize()
      Returns:
      the maximum size of a POST which will be saved by the container during authentication.
    • setMaxSavePostSize Link icon

      public 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 Link icon

      public String getParseBodyMethods()
      Returns:
      the HTTP methods which will support body parameters parsing
    • setParseBodyMethods Link icon

      public void setParseBodyMethods(String methods)
      Set list of HTTP methods which should allow body parameter parsing. This defaults to POST.
      Parameters:
      methods - Comma separated list of HTTP method names
    • isParseBodyMethod Link icon

      protected boolean isParseBodyMethod(String method)
    • getPort Link icon

      public 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.
    • setPort Link icon

      public void setPort(int port)
      Set the port number on which we listen for requests.
      Parameters:
      port - The new port number
    • getPortOffset Link icon

      public int getPortOffset()
    • setPortOffset Link icon

      public void setPortOffset(int portOffset)
    • getPortWithOffset Link icon

      public int getPortWithOffset()
    • getLocalPort Link icon

      public 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 Link icon

      public String getProtocol()
      Returns:
      the Coyote protocol handler in use.
    • getProtocolHandlerClassName Link icon

      public String getProtocolHandlerClassName()
      Returns:
      the class name of the Coyote protocol handler in use.
    • getProtocolHandler Link icon

      public ProtocolHandler getProtocolHandler()
      Returns:
      the protocol handler associated with the connector.
    • getProxyName Link icon

      public String getProxyName()
      Returns:
      the proxy server name for this Connector.
    • setProxyName Link icon

      public void setProxyName(String proxyName)
      Set the proxy server name for this Connector.
      Parameters:
      proxyName - The new proxy server name
    • getProxyPort Link icon

      public int getProxyPort()
      Returns:
      the proxy server port for this Connector.
    • setProxyPort Link icon

      public void setProxyPort(int proxyPort)
      Set the proxy server port for this Connector.
      Parameters:
      proxyPort - The new proxy server port
    • getRedirectPort Link icon

      public 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.
    • setRedirectPort Link icon

      public void setRedirectPort(int redirectPort)
      Set the redirect port number.
      Parameters:
      redirectPort - The redirect port number (non-SSL to SSL)
    • getRedirectPortWithOffset Link icon

      public int getRedirectPortWithOffset()
    • getScheme Link icon

      public String getScheme()
      Returns:
      the scheme that will be assigned to requests received through this connector. Default value is "http".
    • setScheme Link icon

      public void setScheme(String scheme)
      Set the scheme that will be assigned to requests received through this connector.
      Parameters:
      scheme - The new scheme
    • getSecure Link icon

      public boolean getSecure()
      Returns:
      the secure connection flag that will be assigned to requests received through this connector. Default value is "false".
    • setSecure Link icon

      public 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 Link icon

      public String getURIEncoding()
      Returns:
      the name of character encoding to be used for the URI using the original case.
    • getURICharset Link icon

      public Charset getURICharset()
      Returns:
      The Charset to use to convert raw URI bytes (after %nn decoding) to characters. This will never be null
    • setURIEncoding Link icon

      public void setURIEncoding(String URIEncoding)
      Set the URI encoding to be used for the URI.
      Parameters:
      URIEncoding - The new URI character encoding.
    • getUseBodyEncodingForURI Link icon

      public boolean getUseBodyEncodingForURI()
      Returns:
      the true if the entity body encoding should be used for the URI.
    • setUseBodyEncodingForURI Link icon

      public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI)
      Set if the entity body encoding should be used for the URI.
      Parameters:
      useBodyEncodingForURI - The new value for the flag.
    • getXpoweredBy Link icon

      public 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:
      true if generation of X-Powered-By response header is enabled, false otherwise
    • setXpoweredBy Link icon

      public 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
    • setUseIPVHosts Link icon

      public void setUseIPVHosts(boolean useIPVHosts)
      Enable the use of IP-based virtual hosting.
      Parameters:
      useIPVHosts - true if Hosts are identified by IP, false if Hosts are identified by name.
    • getUseIPVHosts Link icon

      public boolean getUseIPVHosts()
      Test if IP-based virtual hosting is enabled.
      Returns:
      true if IP vhosts are enabled
    • getExecutorName Link icon

      public String getExecutorName()
    • addSslHostConfig Link icon

      public void addSslHostConfig(SSLHostConfig sslHostConfig)
    • findSslHostConfigs Link icon

      public SSLHostConfig[] findSslHostConfigs()
    • addUpgradeProtocol Link icon

      public void addUpgradeProtocol(UpgradeProtocol upgradeProtocol)
    • findUpgradeProtocols Link icon

      public UpgradeProtocol[] findUpgradeProtocols()
    • getEncodedReverseSolidusHandling Link icon

      public String getEncodedReverseSolidusHandling()
    • setEncodedReverseSolidusHandling Link icon

      public void setEncodedReverseSolidusHandling(String encodedReverseSolidusHandling)
    • getEncodedReverseSolidusHandlingInternal Link icon

      public EncodedSolidusHandling getEncodedReverseSolidusHandlingInternal()
    • getEncodedSolidusHandling Link icon

      public String getEncodedSolidusHandling()
    • setEncodedSolidusHandling Link icon

      public void setEncodedSolidusHandling(String encodedSolidusHandling)
    • getEncodedSolidusHandlingInternal Link icon

      public EncodedSolidusHandling getEncodedSolidusHandlingInternal()
    • getRejectSuspiciousURIs Link icon

      public boolean getRejectSuspiciousURIs()
    • setRejectSuspiciousURIs Link icon

      public void setRejectSuspiciousURIs(boolean rejectSuspiciousURIs)
    • createRequest Link icon

      public Request createRequest()
      Create (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
    • createResponse Link icon

      public Response createResponse()
      Create (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 Link icon

      protected String createObjectNameKeyProperties(String type)
    • pause Link icon

      public void pause()
      Pause the connector.
    • resume Link icon

      public void resume()
      Resume the connector.
    • initInternal Link icon

      protected void initInternal() throws LifecycleException
      Description copied from class: LifecycleBase
      Sub-classes implement this method to perform any instance initialisation required.
      Overrides:
      initInternal in class LifecycleMBeanBase
      Throws:
      LifecycleException - If the initialisation fails
    • startInternal Link icon

      protected void startInternal() throws LifecycleException
      Begin processing requests via this Connector.
      Specified by:
      startInternal in class LifecycleBase
      Throws:
      LifecycleException - if a fatal startup error occurs
    • stopInternal Link icon

      protected void stopInternal() throws LifecycleException
      Terminate processing requests via this Connector.
      Specified by:
      stopInternal in class LifecycleBase
      Throws:
      LifecycleException - if a fatal shutdown error occurs
    • destroyInternal Link icon

      protected void destroyInternal() throws LifecycleException
      Description copied from class: LifecycleBase
      Sub-classes implement this method to perform any instance destruction required.
      Overrides:
      destroyInternal in class LifecycleMBeanBase
      Throws:
      LifecycleException - If the destruction fails
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • getDomainInternal Link icon

      protected String getDomainInternal()
      Description copied from class: LifecycleMBeanBase
      Method implemented by sub-classes to identify the domain in which MBeans should be registered.
      Specified by:
      getDomainInternal in class LifecycleMBeanBase
      Returns:
      The name of the domain to use to register MBeans.
    • getObjectNameKeyProperties Link icon

      protected String getObjectNameKeyProperties()
      Description copied from class: LifecycleMBeanBase
      Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.
      Specified by:
      getObjectNameKeyProperties in class LifecycleMBeanBase
      Returns:
      The string representation of the key properties component of the desired ObjectName