Class InvokeHTTP

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

@SupportsSensitiveDynamicProperties @SupportsBatching @Tags({"http","https","rest","client"}) @InputRequirement(INPUT_ALLOWED) @CapabilityDescription("An HTTP client processor which can interact with a configurable HTTP Endpoint. The destination URL and HTTP Method are configurable. When the HTTP Method is PUT, POST or PATCH, the FlowFile contents are included as the body of the request and FlowFile attributes are converted to HTTP headers, optionally, based on configuration properties.") @WritesAttribute(attribute="invokehttp.status.code",description="The status code that is returned") @WritesAttribute(attribute="invokehttp.status.message",description="The status message that is returned") @WritesAttribute(attribute="invokehttp.response.body",description="In the instance where the status code received is not a success (2xx) then the response body will be put to the \'invokehttp.response.body\' attribute of the request FlowFile.") @WritesAttribute(attribute="invokehttp.request.url",description="The original request URL") @WritesAttribute(attribute="invokehttp.request.duration",description="Duration (in milliseconds) of the HTTP call to the external endpoint") @WritesAttribute(attribute="invokehttp.response.url",description="The URL that was ultimately requested after any redirects were followed") @WritesAttribute(attribute="invokehttp.tx.id",description="The transaction ID that is returned after reading the response") @WritesAttribute(attribute="invokehttp.remote.dn",description="The DN of the remote server") @WritesAttribute(attribute="invokehttp.java.exception.class",description="The Java exception class raised when the processor fails") @WritesAttribute(attribute="invokehttp.java.exception.message",description="The Java exception message raised when the processor fails") @WritesAttribute(attribute="user-defined",description="If the \'Put Response Body In Attribute\' property is set then whatever it is set to will become the attribute key and the value would be the body of the HTTP response.") @DynamicProperty(name="Header Name",value="Attribute Expression Language",expressionLanguageScope=FLOWFILE_ATTRIBUTES,description="Send request header with a key matching the Dynamic Property Key and a value created by evaluating the Attribute Expression Language set in the value of the Dynamic Property.") @DynamicProperty(name="post:form:<NAME>",value="Attribute Expression Language",expressionLanguageScope=FLOWFILE_ATTRIBUTES,description="When the HTTP Method is POST, dynamic properties with the property name in the form of post:form:<NAME>, where the <NAME> will be the form data name, will be used to fill out the multipart form parts. If send message body is false, the flowfile will not be sent, but any other form data will be.") public class InvokeHTTP extends org.apache.nifi.processor.AbstractProcessor
  • Field Details

    • STATUS_CODE

      public static final String STATUS_CODE
      See Also:
    • STATUS_MESSAGE

      public static final String STATUS_MESSAGE
      See Also:
    • RESPONSE_BODY

      public static final String RESPONSE_BODY
      See Also:
    • REQUEST_URL

      public static final String REQUEST_URL
      See Also:
    • REQUEST_DURATION

      public static final String REQUEST_DURATION
      See Also:
    • RESPONSE_URL

      public static final String RESPONSE_URL
      See Also:
    • TRANSACTION_ID

      public static final String TRANSACTION_ID
      See Also:
    • REMOTE_DN

      public static final String REMOTE_DN
      See Also:
    • EXCEPTION_CLASS

      public static final String EXCEPTION_CLASS
      See Also:
    • EXCEPTION_MESSAGE

      public static final String EXCEPTION_MESSAGE
      See Also:
    • DEFAULT_CONTENT_TYPE

      public static final String DEFAULT_CONTENT_TYPE
      See Also:
    • FORM_DATA_NAME_BASE

      protected static final String FORM_DATA_NAME_BASE
      See Also:
    • FORM_DATA_NAME_PARAMETER_PATTERN

      private static final Pattern FORM_DATA_NAME_PARAMETER_PATTERN
    • FORM_DATA_NAME_GROUP

      private static final String FORM_DATA_NAME_GROUP
      See Also:
    • IGNORED_REQUEST_ATTRIBUTES

      private static final Set<String> IGNORED_REQUEST_ATTRIBUTES
    • HTTP_METHOD

      public static final org.apache.nifi.components.PropertyDescriptor HTTP_METHOD
    • HTTP_URL

      public static final org.apache.nifi.components.PropertyDescriptor HTTP_URL
    • HTTP2_DISABLED

      public static final org.apache.nifi.components.PropertyDescriptor HTTP2_DISABLED
    • SSL_CONTEXT_SERVICE

      public static final org.apache.nifi.components.PropertyDescriptor SSL_CONTEXT_SERVICE
    • SOCKET_CONNECT_TIMEOUT

      public static final org.apache.nifi.components.PropertyDescriptor SOCKET_CONNECT_TIMEOUT
    • SOCKET_READ_TIMEOUT

      public static final org.apache.nifi.components.PropertyDescriptor SOCKET_READ_TIMEOUT
    • SOCKET_WRITE_TIMEOUT

      public static final org.apache.nifi.components.PropertyDescriptor SOCKET_WRITE_TIMEOUT
    • SOCKET_IDLE_TIMEOUT

      public static final org.apache.nifi.components.PropertyDescriptor SOCKET_IDLE_TIMEOUT
    • SOCKET_IDLE_CONNECTIONS

      public static final org.apache.nifi.components.PropertyDescriptor SOCKET_IDLE_CONNECTIONS
    • REQUEST_OAUTH2_ACCESS_TOKEN_PROVIDER

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_OAUTH2_ACCESS_TOKEN_PROVIDER
    • REQUEST_OAUTH2_REFRESH_TOKEN

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_OAUTH2_REFRESH_TOKEN
    • REQUEST_USERNAME

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_USERNAME
    • REQUEST_PASSWORD

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_PASSWORD
    • REQUEST_DIGEST_AUTHENTICATION_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_DIGEST_AUTHENTICATION_ENABLED
    • REQUEST_FAILURE_PENALIZATION_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FAILURE_PENALIZATION_ENABLED
    • REQUEST_BODY_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_BODY_ENABLED
    • REQUEST_FORM_DATA_NAME

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FORM_DATA_NAME
    • REQUEST_FORM_DATA_FILENAME_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_FORM_DATA_FILENAME_ENABLED
    • REQUEST_CHUNKED_TRANSFER_ENCODING_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CHUNKED_TRANSFER_ENCODING_ENABLED
    • REQUEST_CONTENT_ENCODING

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CONTENT_ENCODING
    • REQUEST_CONTENT_TYPE

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_CONTENT_TYPE
    • REQUEST_DATE_HEADER_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_DATE_HEADER_ENABLED
    • REQUEST_HEADER_ATTRIBUTES_PATTERN

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_HEADER_ATTRIBUTES_PATTERN
    • REQUEST_USER_AGENT

      public static final org.apache.nifi.components.PropertyDescriptor REQUEST_USER_AGENT
    • RESPONSE_BODY_ATTRIBUTE_NAME

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_NAME
    • RESPONSE_BODY_ATTRIBUTE_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_SIZE
    • RESPONSE_BODY_IGNORED

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_BODY_IGNORED
    • RESPONSE_CACHE_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_CACHE_ENABLED
    • RESPONSE_CACHE_SIZE

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_CACHE_SIZE
    • RESPONSE_GENERATION_REQUIRED

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_GENERATION_REQUIRED
    • RESPONSE_FLOW_FILE_NAMING_STRATEGY

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_FLOW_FILE_NAMING_STRATEGY
    • RESPONSE_HEADER_REQUEST_ATTRIBUTES_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_HEADER_REQUEST_ATTRIBUTES_ENABLED
    • RESPONSE_HEADER_REQUEST_ATTRIBUTES_PREFIX

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_HEADER_REQUEST_ATTRIBUTES_PREFIX
    • RESPONSE_REDIRECTS_ENABLED

      public static final org.apache.nifi.components.PropertyDescriptor RESPONSE_REDIRECTS_ENABLED
    • PROXY_SPECS

      private static final ProxySpec[] PROXY_SPECS
    • PROXY_CONFIGURATION_SERVICE

      private static final org.apache.nifi.components.PropertyDescriptor PROXY_CONFIGURATION_SERVICE
    • PROPERTY_DESCRIPTORS

      public static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • ORIGINAL

      public static final org.apache.nifi.processor.Relationship ORIGINAL
    • RESPONSE

      public static final org.apache.nifi.processor.Relationship RESPONSE
    • RETRY

      public static final org.apache.nifi.processor.Relationship RETRY
    • NO_RETRY

      public static final org.apache.nifi.processor.Relationship NO_RETRY
    • FAILURE

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

      public static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • RFC_2616_DATE_TIME

      private static final DateTimeFormatter RFC_2616_DATE_TIME
    • MULTIPLE_HEADER_DELIMITER

      private static final String MULTIPLE_HEADER_DELIMITER
      See Also:
    • dynamicPropertyNames

      private volatile Set<String> dynamicPropertyNames
    • requestHeaderAttributesPattern

      private volatile Pattern requestHeaderAttributesPattern
    • oauth2AccessTokenProviderOptional

      private volatile Optional<OAuth2AccessTokenProvider> oauth2AccessTokenProviderOptional
    • okHttpClientAtomicReference

      private final AtomicReference<okhttp3.OkHttpClient> okHttpClientAtomicReference
  • Constructor Details

    • InvokeHTTP

      public InvokeHTTP()
  • Method Details

    • getSupportedPropertyDescriptors

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

      protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
      Overrides:
      getSupportedDynamicPropertyDescriptor in class org.apache.nifi.components.AbstractConfigurableComponent
    • migrateProperties

      public void migrateProperties(PropertyConfiguration config)
    • 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
    • onPropertyModified

      public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
      Specified by:
      onPropertyModified in interface org.apache.nifi.components.ConfigurableComponent
      Overrides:
      onPropertyModified in class org.apache.nifi.components.AbstractConfigurableComponent
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • setUpClient

      @OnScheduled public void setUpClient(org.apache.nifi.processor.ProcessContext context) throws IOException
      Throws:
      IOException
    • initOauth2AccessTokenProvider

      @OnScheduled public void initOauth2AccessTokenProvider(org.apache.nifi.processor.ProcessContext context)
    • setAuthenticator

      private void setAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder, org.apache.nifi.processor.ProcessContext context)
    • 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
    • configureRequest

      private okhttp3.Request configureRequest(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.flowfile.FlowFile requestFlowFile, String url)
    • getRequestBodyToSend

      private okhttp3.RequestBody getRequestBodyToSend(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile requestFlowFile, ContentEncodingStrategy contentEncodingStrategy)
    • setHeaderProperties

      private void setHeaderProperties(org.apache.nifi.processor.ProcessContext context, okhttp3.Request.Builder requestBuilder, org.apache.nifi.flowfile.FlowFile requestFlowFile)
    • route

      private void route(org.apache.nifi.flowfile.FlowFile request, org.apache.nifi.flowfile.FlowFile response, org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, int statusCode)
    • isSuccess

      private boolean isSuccess(int statusCode)
    • convertAttributesFromHeaders

      private Map<String,String> convertAttributesFromHeaders(okhttp3.Response responseHttp, String prefix)
      Returns a Map of flowfile attributes from the response http headers. Multivalue headers are naively converted to comma separated strings. Prefix is passed in to allow differentiation for these new attributes.
    • getCharsetFromMediaType

      private Charset getCharsetFromMediaType(okhttp3.MediaType contentType)
    • getResponseCacheDirectory

      private static File getResponseCacheDirectory() throws IOException
      Throws:
      IOException
    • getFlowFileNamingStrategy

      private FlowFileNamingStrategy getFlowFileNamingStrategy(org.apache.nifi.processor.ProcessContext context)
    • getFileNameFromUrl

      private String getFileNameFromUrl(URL url)
    • findRequestMethod

      private Optional<HttpMethod> findRequestMethod(String method)
    • getRequestMethod

      private String getRequestMethod(org.apache.nifi.context.PropertyContext context, org.apache.nifi.flowfile.FlowFile flowFile)