@SupportsSensitiveDynamicProperties @SupportsBatching @Tags(value={"http","https","rest","client"}) @InputRequirement(value=INPUT_ALLOWED) @CapabilityDescription(value="An HTTP client processor which can interact with a configurable HTTP Endpoint. The destination URL and HTTP Method are configurable. FlowFile attributes are converted to HTTP headers and the FlowFile contents are included as the body of the request (if the HTTP Method is PUT, POST or PATCH).") @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 AbstractProcessor
| Constructor and Description |
|---|
InvokeHTTP() |
| Modifier and Type | Method and Description |
|---|---|
private okhttp3.Request |
configureRequest(ProcessContext context,
ProcessSession session,
FlowFile requestFlowFile,
URL url) |
private Map<String,String> |
convertAttributesFromHeaders(okhttp3.Response responseHttp)
Returns a Map of flowfile attributes from the response http headers.
|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
private Optional<HttpMethod> |
findRequestMethod(String method) |
private Charset |
getCharsetFromMediaType(okhttp3.MediaType contentType) |
private String |
getFileNameFromUrl(URL url) |
private FlowFileNamingStrategy |
getFlowFileNamingStrategy(ProcessContext context) |
private String |
getLogString(Map<String,List<String>> map) |
Set<Relationship> |
getRelationships() |
private okhttp3.RequestBody |
getRequestBodyToSend(ProcessSession session,
ProcessContext context,
FlowFile requestFlowFile,
ContentEncodingStrategy contentEncodingStrategy) |
private String |
getRequestMethod(PropertyContext context,
FlowFile flowFile) |
private static File |
getResponseCacheDirectory() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
initOauth2AccessTokenProvider(ProcessContext context) |
private boolean |
isSuccess(int statusCode) |
private void |
logRequest(ComponentLog logger,
okhttp3.Request request) |
private void |
logResponse(ComponentLog logger,
URL url,
okhttp3.Response response) |
void |
onPropertyModified(PropertyDescriptor descriptor,
String oldValue,
String newValue) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
route(FlowFile request,
FlowFile response,
ProcessSession session,
ProcessContext context,
int statusCode) |
private void |
setAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder,
ProcessContext context) |
private void |
setHeaderProperties(ProcessContext context,
okhttp3.Request.Builder requestBuilder,
FlowFile requestFlowFile) |
void |
setUpClient(ProcessContext context) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, validatepublic static final String STATUS_CODE
public static final String STATUS_MESSAGE
public static final String RESPONSE_BODY
public static final String REQUEST_URL
public static final String REQUEST_DURATION
public static final String RESPONSE_URL
public static final String TRANSACTION_ID
public static final String REMOTE_DN
public static final String EXCEPTION_CLASS
public static final String EXCEPTION_MESSAGE
public static final String DEFAULT_CONTENT_TYPE
protected static final String FORM_DATA_NAME_BASE
private static final Pattern FORM_DATA_NAME_PARAMETER_PATTERN
private static final String FORM_DATA_NAME_GROUP
public static final PropertyDescriptor HTTP_METHOD
public static final PropertyDescriptor HTTP_URL
public static final PropertyDescriptor HTTP2_DISABLED
public static final PropertyDescriptor SSL_CONTEXT_SERVICE
public static final PropertyDescriptor SOCKET_CONNECT_TIMEOUT
public static final PropertyDescriptor SOCKET_READ_TIMEOUT
public static final PropertyDescriptor SOCKET_WRITE_TIMEOUT
public static final PropertyDescriptor SOCKET_IDLE_TIMEOUT
public static final PropertyDescriptor SOCKET_IDLE_CONNECTIONS
@Deprecated public static final PropertyDescriptor PROXY_HOST
@Deprecated public static final PropertyDescriptor PROXY_PORT
@Deprecated public static final PropertyDescriptor PROXY_TYPE
@Deprecated public static final PropertyDescriptor PROXY_USERNAME
@Deprecated public static final PropertyDescriptor PROXY_PASSWORD
public static final PropertyDescriptor REQUEST_OAUTH2_ACCESS_TOKEN_PROVIDER
public static final PropertyDescriptor REQUEST_USERNAME
public static final PropertyDescriptor REQUEST_PASSWORD
public static final PropertyDescriptor REQUEST_DIGEST_AUTHENTICATION_ENABLED
public static final PropertyDescriptor REQUEST_FAILURE_PENALIZATION_ENABLED
public static final PropertyDescriptor REQUEST_BODY_ENABLED
public static final PropertyDescriptor REQUEST_FORM_DATA_NAME
public static final PropertyDescriptor REQUEST_FORM_DATA_FILENAME_ENABLED
public static final PropertyDescriptor REQUEST_CHUNKED_TRANSFER_ENCODING_ENABLED
public static final PropertyDescriptor REQUEST_CONTENT_ENCODING
public static final PropertyDescriptor REQUEST_CONTENT_TYPE
public static final PropertyDescriptor REQUEST_DATE_HEADER_ENABLED
public static final PropertyDescriptor REQUEST_HEADER_ATTRIBUTES_PATTERN
public static final PropertyDescriptor REQUEST_USER_AGENT
public static final PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_NAME
public static final PropertyDescriptor RESPONSE_BODY_ATTRIBUTE_SIZE
public static final PropertyDescriptor RESPONSE_BODY_IGNORED
public static final PropertyDescriptor RESPONSE_CACHE_ENABLED
public static final PropertyDescriptor RESPONSE_CACHE_SIZE
public static final PropertyDescriptor RESPONSE_COOKIE_STRATEGY
public static final PropertyDescriptor RESPONSE_GENERATION_REQUIRED
public static final PropertyDescriptor RESPONSE_FLOW_FILE_NAMING_STRATEGY
public static final PropertyDescriptor RESPONSE_HEADER_REQUEST_ATTRIBUTES_ENABLED
public static final PropertyDescriptor RESPONSE_REDIRECTS_ENABLED
private static final ProxySpec[] PROXY_SPECS
private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
public static final List<PropertyDescriptor> PROPERTIES
public static final Relationship ORIGINAL
public static final Relationship RESPONSE
public static final Relationship RETRY
public static final Relationship NO_RETRY
public static final Relationship FAILURE
public static final Set<Relationship> RELATIONSHIPS
private static final DateTimeFormatter RFC_2616_DATE_TIME
private static final String MULTIPLE_HEADER_DELIMITER
private static final DeprecationLogger deprecationLogger
private volatile Pattern requestHeaderAttributesPattern
private volatile boolean chunkedTransferEncoding
private volatile Optional<OAuth2AccessTokenProvider> oauth2AccessTokenProviderOptional
private final AtomicReference<okhttp3.OkHttpClient> okHttpClientAtomicReference
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified in interface ConfigurableComponentonPropertyModified in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponent@OnScheduled public void setUpClient(ProcessContext context) throws TlsException, IOException
TlsExceptionIOException@OnScheduled public void initOauth2AccessTokenProvider(ProcessContext context)
private void setAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder,
ProcessContext context)
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate okhttp3.Request configureRequest(ProcessContext context, ProcessSession session, FlowFile requestFlowFile, URL url)
private okhttp3.RequestBody getRequestBodyToSend(ProcessSession session, ProcessContext context, FlowFile requestFlowFile, ContentEncodingStrategy contentEncodingStrategy)
private void setHeaderProperties(ProcessContext context, okhttp3.Request.Builder requestBuilder, FlowFile requestFlowFile)
private void route(FlowFile request, FlowFile response, ProcessSession session, ProcessContext context, int statusCode)
private boolean isSuccess(int statusCode)
private void logRequest(ComponentLog logger, okhttp3.Request request)
private void logResponse(ComponentLog logger, URL url, okhttp3.Response response)
private Map<String,String> convertAttributesFromHeaders(okhttp3.Response responseHttp)
private Charset getCharsetFromMediaType(okhttp3.MediaType contentType)
private static File getResponseCacheDirectory() throws IOException
IOExceptionprivate FlowFileNamingStrategy getFlowFileNamingStrategy(ProcessContext context)
private Optional<HttpMethod> findRequestMethod(String method)
private String getRequestMethod(PropertyContext context, FlowFile flowFile)
Copyright © 2023 Apache NiFi Project. All rights reserved.