Class HandleHttpRequest

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.HandleHttpRequest
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@InputRequirement(INPUT_FORBIDDEN) @Tags({"http","https","request","listen","ingress","web service"}) @CapabilityDescription("Starts an HTTP Server and listens for HTTP Requests. For each request, creates a FlowFile and transfers to \'success\'. This Processor is designed to be used in conjunction with the HandleHttpResponse Processor in order to create a Web Service. In case of a multipart request, one FlowFile is generated for each part.") @WritesAttribute(attribute="http.context.identifier",description="An identifier that allows the HandleHttpRequest and HandleHttpResponse to coordinate which FlowFile belongs to which HTTP Request/Response.") @WritesAttribute(attribute="mime.type",description="The MIME Type of the data, according to the HTTP Header \"Content-Type\"") @WritesAttribute(attribute="http.servlet.path",description="The part of the request URL that is considered the Servlet Path") @WritesAttribute(attribute="http.context.path",description="The part of the request URL that is considered to be the Context Path") @WritesAttribute(attribute="http.method",description="The HTTP Method that was used for the request, such as GET or POST") @WritesAttribute(attribute="http.local.name",description="IP address/hostname of the server") @WritesAttribute(attribute="http.server.port",description="Listening port of the server") @WritesAttribute(attribute="http.query.string",description="The query string portion of the Request URL") @WritesAttribute(attribute="http.remote.host",description="The hostname of the requestor") @WritesAttribute(attribute="http.remote.addr",description="The hostname:port combination of the requestor") @WritesAttribute(attribute="http.remote.user",description="The username of the requestor") @WritesAttribute(attribute="http.protocol",description="The protocol used to communicate") @WritesAttribute(attribute="http.request.uri",description="The full Request URL") @WritesAttribute(attribute="http.auth.type",description="The type of HTTP Authorization used") @WritesAttribute(attribute="http.principal.name",description="The name of the authenticated user making the request") @WritesAttribute(attribute="http.query.param.XXX",description="Each of query parameters in the request will be added as an attribute, prefixed with \"http.query.param.\"") @WritesAttribute(attribute="http.param.XXX",description="Form parameters in the request that are configured by \"Parameters to Attributes List\" will be added as an attribute, prefixed with \"http.param.\". Putting form parameters of large size is not recommended.") @WritesAttribute(attribute="http.subject.dn",description="The Distinguished Name of the requestor. This value will not be populated unless the Processor is configured to use an SSLContext Service") @WritesAttribute(attribute="http.issuer.dn",description="The Distinguished Name of the entity that issued the Subject\'s certificate. This value will not be populated unless the Processor is configured to use an SSLContext Service") @WritesAttribute(attribute="http.certificate.sans.N.name",description="X.509 Client Certificate Subject Alternative Name value from mutual TLS authentication. The attribute name has a zero-based index ordered according to the content of Client Certificate") @WritesAttribute(attribute="http.certificate.sans.N.nameType",description="X.509 Client Certificate Subject Alternative Name type from mutual TLS authentication. The attribute name has a zero-based index ordered according to the content of Client Certificate. The attribute value is one of the General Names from RFC 3280 Section 4.1.2.7") @WritesAttribute(attribute="http.headers.XXX",description="Each of the HTTP Headers that is received in the request will be added as an attribute, prefixed with \"http.headers.\" For example, if the request contains an HTTP Header named \"x-my-header\", then the value will be added to an attribute named \"http.headers.x-my-header\"") @WritesAttribute(attribute="http.headers.multipart.XXX",description="Each of the HTTP Headers that is received in the multipart request will be added as an attribute, prefixed with \"http.headers.multipart.\" For example, if the multipart request contains an HTTP Header named \"content-disposition\", then the value will be added to an attribute named \"http.headers.multipart.content-disposition\"") @WritesAttribute(attribute="http.multipart.size",description="For requests with Content-Type \"multipart/form-data\", the part\'s content size is recorded into this attribute") @WritesAttribute(attribute="http.multipart.content.type",description="For requests with Content-Type \"multipart/form-data\", the part\'s content type is recorded into this attribute") @WritesAttribute(attribute="http.multipart.name",description="For requests with Content-Type \"multipart/form-data\", the part\'s name is recorded into this attribute") @WritesAttribute(attribute="http.multipart.filename",description="For requests with Content-Type \"multipart/form-data\", when the part contains an uploaded file, the name of the file is recorded into this attribute. Files are stored temporarily at the default temporary-file directory specified in \"java.io.File\" Java Docs)") @WritesAttribute(attribute="http.multipart.fragments.sequence.number",description="For requests with Content-Type \"multipart/form-data\", the part\'s index is recorded into this attribute. The index starts with 1.") @WritesAttribute(attribute="http.multipart.fragments.total.number",description="For requests with Content-Type \"multipart/form-data\", the count of all parts is recorded into this attribute.") @SeeAlso(HandleHttpResponse.class) public class HandleHttpRequest extends org.apache.nifi.processor.AbstractProcessor
  • Field Details

    • MIME_TYPE__MULTIPART_FORM_DATA

      private static final String MIME_TYPE__MULTIPART_FORM_DATA
      See Also:
    • URL_QUERY_PARAM_DELIMITER

      private static final Pattern URL_QUERY_PARAM_DELIMITER
    • CLIENT_NONE

      public static final org.apache.nifi.components.AllowableValue CLIENT_NONE
    • CLIENT_WANT

      public static final org.apache.nifi.components.AllowableValue CLIENT_WANT
    • CLIENT_NEED

      public static final org.apache.nifi.components.AllowableValue CLIENT_NEED
    • PORT

      public static final org.apache.nifi.components.PropertyDescriptor PORT
    • HOSTNAME

      public static final org.apache.nifi.components.PropertyDescriptor HOSTNAME
    • HTTP_CONTEXT_MAP

      public static final org.apache.nifi.components.PropertyDescriptor HTTP_CONTEXT_MAP
    • SSL_CONTEXT

      public static final org.apache.nifi.components.PropertyDescriptor SSL_CONTEXT
    • HTTP_PROTOCOL_STRATEGY

      public static final org.apache.nifi.components.PropertyDescriptor HTTP_PROTOCOL_STRATEGY
    • URL_CHARACTER_SET

      public static final org.apache.nifi.components.PropertyDescriptor URL_CHARACTER_SET
    • PATH_REGEX

      public static final org.apache.nifi.components.PropertyDescriptor PATH_REGEX
    • ALLOW_GET

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_GET
    • ALLOW_POST

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_POST
    • ALLOW_PUT

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_PUT
    • ALLOW_DELETE

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_DELETE
    • ALLOW_HEAD

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_HEAD
    • ALLOW_OPTIONS

      public static final org.apache.nifi.components.PropertyDescriptor ALLOW_OPTIONS
    • MAXIMUM_THREADS

      public static final org.apache.nifi.components.PropertyDescriptor MAXIMUM_THREADS
    • REQUEST_HEADER_MAX_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_HEADER_MAX_SIZE
    • ADDITIONAL_METHODS

      public static final org.apache.nifi.components.PropertyDescriptor ADDITIONAL_METHODS
    • PARAMETERS_TO_ATTRIBUTES

      public static final org.apache.nifi.components.PropertyDescriptor PARAMETERS_TO_ATTRIBUTES
    • CLIENT_AUTH

      public static final org.apache.nifi.components.PropertyDescriptor CLIENT_AUTH
    • CONTAINER_QUEUE_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor CONTAINER_QUEUE_SIZE
    • MULTIPART_REQUEST_MAX_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor MULTIPART_REQUEST_MAX_SIZE
    • MULTIPART_READ_BUFFER_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor MULTIPART_READ_BUFFER_SIZE
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • RELATIONSHIPS

      private static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • server

      private volatile org.eclipse.jetty.server.Server server
    • ready

      private volatile boolean ready
    • containerQueue

      private volatile BlockingQueue<HandleHttpRequest.HttpRequestContainer> containerQueue
    • initialized

      private final AtomicBoolean initialized
    • runOnPrimary

      private final AtomicBoolean runOnPrimary
    • parameterToAttributesReference

      private final AtomicReference<Set<String>> parameterToAttributesReference
    • certificateAttributesProvider

      private final CertificateAttributesProvider certificateAttributesProvider
  • Constructor Details

    • HandleHttpRequest

      public HandleHttpRequest()
  • Method Details

    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • clearInit

      @OnScheduled public void clearInit()
    • initializeServer

      void initializeServer(org.apache.nifi.processor.ProcessContext context) throws Exception
      Throws:
      Exception
    • getPort

      protected int getPort()
    • getRequestQueueSize

      protected int getRequestQueueSize()
    • shutdown

      @OnUnscheduled public void shutdown() throws Exception
      Throws:
      Exception
    • drainContainerQueue

      void drainContainerQueue()
    • onPrimaryNodeChange

      @OnPrimaryNodeStateChange public void onPrimaryNodeChange(org.apache.nifi.annotation.notification.PrimaryNodeState state)
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • savePartAttributes

      private org.apache.nifi.flowfile.FlowFile savePartAttributes(org.apache.nifi.processor.ProcessSession session, jakarta.servlet.http.Part part, org.apache.nifi.flowfile.FlowFile flowFile, int i, int allPartsCount)
    • saveRequestAttributes

      private org.apache.nifi.flowfile.FlowFile saveRequestAttributes(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, jakarta.servlet.http.HttpServletRequest request, org.apache.nifi.flowfile.FlowFile flowFile, String contextIdentifier)
    • forwardFlowFile

      private void forwardFlowFile(org.apache.nifi.processor.ProcessSession session, long start, jakarta.servlet.http.HttpServletRequest request, org.apache.nifi.flowfile.FlowFile flowFile)
    • registerRequest

      private boolean registerRequest(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, HandleHttpRequest.HttpRequestContainer container, org.apache.nifi.flowfile.FlowFile flowFile)
    • handleFlowContentStreamingError

      protected void handleFlowContentStreamingError(org.apache.nifi.processor.ProcessSession session, HandleHttpRequest.HttpRequestContainer container, Optional<org.apache.nifi.flowfile.FlowFile> flowFile, Exception e)
    • putAttribute

      private void putAttribute(Map<String,String> map, String key, Object value)
    • putAttribute

      private void putAttribute(Map<String,String> map, String key, String value)
    • sendError

      private void sendError(int statusCode, String message, HandleHttpRequest.HttpRequestContainer container)
    • sendError

      private void sendError(int statusCode, String message, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    • createServer

      private org.eclipse.jetty.server.Server createServer(org.apache.nifi.processor.ProcessContext context)