@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 request URL") @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
Modifier and Type | Class and Description |
---|---|
private static class |
InvokeHTTP.OverrideHostnameVerifier |
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(URL url,
okhttp3.Response responseHttp)
Returns a Map of flowfile attributes from the response http headers.
|
private String |
csv(Collection<String> values)
Convert a collection of string values into a overly simple comma separated string.
|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
private Charset |
getCharsetFromMediaType(okhttp3.MediaType contentType) |
private static File |
getETagCacheDir()
Retrieve the directory in which OkHttp should cache responses.
|
private String |
getLogString(Map<String,List<String>> map) |
Set<Relationship> |
getRelationships() |
private okhttp3.RequestBody |
getRequestBodyToSend(ProcessSession session,
ProcessContext context,
FlowFile requestFlowFile) |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext 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 okhttp3.Request.Builder |
setHeaderProperties(ProcessContext context,
okhttp3.Request.Builder requestBuilder,
FlowFile requestFlowFile) |
void |
setUpClient(ProcessContext context) |
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, validate
public 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 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
public static final String FORM_BASE
public static final String HTTP
public static final String HTTPS
private static final Pattern DYNAMIC_FORM_PARAMETER_NAME
public static final PropertyDescriptor PROP_METHOD
public static final PropertyDescriptor PROP_URL
public static final PropertyDescriptor PROP_CONNECT_TIMEOUT
public static final PropertyDescriptor PROP_READ_TIMEOUT
public static final PropertyDescriptor PROP_IDLE_TIMEOUT
public static final PropertyDescriptor PROP_MAX_IDLE_CONNECTIONS
public static final PropertyDescriptor PROP_DATE_HEADER
public static final PropertyDescriptor PROP_FOLLOW_REDIRECTS
public static final PropertyDescriptor PROP_ATTRIBUTES_TO_SEND
public static final PropertyDescriptor PROP_USERAGENT
public static final PropertyDescriptor PROP_SSL_CONTEXT_SERVICE
public static final PropertyDescriptor PROP_PROXY_TYPE
public static final PropertyDescriptor PROP_PROXY_HOST
public static final PropertyDescriptor PROP_PROXY_PORT
public static final PropertyDescriptor PROP_PROXY_USER
public static final PropertyDescriptor PROP_PROXY_PASSWORD
public static final PropertyDescriptor PROP_CONTENT_TYPE
public static final PropertyDescriptor PROP_SEND_BODY
public static final PropertyDescriptor PROP_FORM_BODY_FORM_NAME
public static final PropertyDescriptor PROP_SET_FORM_FILE_NAME
public static final PropertyDescriptor PROP_BASIC_AUTH_USERNAME
public static final PropertyDescriptor PROP_BASIC_AUTH_PASSWORD
public static final PropertyDescriptor PROP_PUT_OUTPUT_IN_ATTRIBUTE
public static final PropertyDescriptor PROP_PUT_ATTRIBUTE_MAX_LENGTH
public static final PropertyDescriptor PROP_DIGEST_AUTH
public static final PropertyDescriptor PROP_OUTPUT_RESPONSE_REGARDLESS
public static final PropertyDescriptor PROP_ADD_HEADERS_TO_REQUEST
public static final PropertyDescriptor PROP_USE_CHUNKED_ENCODING
public static final PropertyDescriptor PROP_PENALIZE_NO_RETRY
public static final PropertyDescriptor PROP_USE_ETAG
public static final PropertyDescriptor PROP_ETAG_MAX_CACHE_SIZE
public static final PropertyDescriptor IGNORE_RESPONSE_CONTENT
private static final ProxySpec[] PROXY_SPECS
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
public static final List<PropertyDescriptor> PROPERTIES
public static final Relationship REL_SUCCESS_REQ
public static final Relationship REL_RESPONSE
public static final Relationship REL_RETRY
public static final Relationship REL_NO_RETRY
public static final Relationship REL_FAILURE
public static final Set<Relationship> RELATIONSHIPS
private static final String RFC_1123
private static final org.joda.time.format.DateTimeFormatter DATE_FORMAT
private final AtomicReference<okhttp3.OkHttpClient> okHttpClientAtomicReference
private volatile Pattern regexAttributesToSend
private volatile boolean useChunked
protected void init(ProcessorInitializationContext context)
init
in class AbstractSessionFactoryProcessor
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
onPropertyModified
in interface ConfigurableComponent
onPropertyModified
in class AbstractConfigurableComponent
protected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate
in class AbstractConfigurableComponent
@OnScheduled public void setUpClient(ProcessContext context) throws IOException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException
private void setAuthenticator(okhttp3.OkHttpClient.Builder okHttpClientBuilder, ProcessContext context)
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger
in class AbstractProcessor
ProcessException
private okhttp3.Request configureRequest(ProcessContext context, ProcessSession session, FlowFile requestFlowFile, URL url)
private okhttp3.RequestBody getRequestBodyToSend(ProcessSession session, ProcessContext context, FlowFile requestFlowFile)
private okhttp3.Request.Builder 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 String csv(Collection<String> values)
private Map<String,String> convertAttributesFromHeaders(URL url, okhttp3.Response responseHttp)
private Charset getCharsetFromMediaType(okhttp3.MediaType contentType)
private static File getETagCacheDir()
Ref: https://github.com/square/okhttp/wiki/Recipes#response-caching
Copyright © 2020 Apache NiFi Project. All rights reserved.