public final class RequestExtractor extends Object
RequestExtractor provides utility functions for extracting different aspects of the request.
It provides functionality to extract headers and content.| Modifier and Type | Field and Description |
|---|---|
static String |
CHARSET_HEADER |
static String |
CONTENT_TYPE_HEADER |
| Constructor and Description |
|---|
RequestExtractor(io.cdap.cdap.api.service.http.HttpServiceRequest request) |
| Modifier and Type | Method and Description |
|---|---|
ConnectionMeta |
getConnectionMeta()
Get a ConnectionMeta object from the request body.
|
ConnectionMeta |
getConnectionMeta(ConnectionType expectedType)
Get a ConnectionMeta object from the request body.
|
byte[] |
getContent() |
String |
getContent(Charset charset)
Returns the content by converting it to UNICODE from the provided charset.
|
String |
getContent(String charset) |
<T> T |
getContent(String charset,
Class<T> type)
Returns the content transformed into a Class defined.
|
String |
getHeader(String name,
String defaultValue)
Extracts the HTTP header, if the header is not present, then default value is returned.
|
public static final String CONTENT_TYPE_HEADER
public static final String CHARSET_HEADER
public RequestExtractor(io.cdap.cdap.api.service.http.HttpServiceRequest request)
public String getHeader(String name, String defaultValue)
name - of the HTTP header to be extracted.defaultValue - value to returned if header doesn't exist.@Nullable public byte[] getContent()
@Nullable public String getContent(Charset charset)
charset - of the content being extracted and converted to UNICODE.public ConnectionMeta getConnectionMeta()
IllegalArgumentException - if the body is empty or not a valid ConnectionMetapublic ConnectionMeta getConnectionMeta(ConnectionType expectedType)
IllegalArgumentException - if the body is empty or not a valid ConnectionMeta@Nullable public <T> T getContent(String charset, Class<T> type)
charset - source charset of the content.type - class to converted to.Copyright © 2020 CDAP Licensed under the Apache License, Version 2.0.