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 |
static String |
CONTENT_TYPE |
| Constructor and Description |
|---|
RequestExtractor(io.cdap.cdap.api.service.http.HttpServiceRequest request) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getContent() |
String |
getContent(Charset charset)
Returns the content by converting it to UNICODE from the provided charset.
|
String |
getContent(String charset) |
<T> T |
getHeader(String name,
String defaultValue)
Extracts the HTTP header, if the header is not present, then default value is returned.
|
boolean |
hasHeader(String name)
Checks if the request has a HTTP header.
|
boolean |
isContentType(String expectedType)
Checks if the 'Content-Type' matches expected.
|
public static final String CONTENT_TYPE
public static final String CHARSET
public RequestExtractor(io.cdap.cdap.api.service.http.HttpServiceRequest request)
public boolean hasHeader(String name)
name - of the header to be checked.public <T> T getHeader(String name, String defaultValue)
name - of the HTTP header to be extracted.defaultValue - value to returned if header doesn't exist.public byte[] getContent()
public String getContent(Charset charset)
charset - of the content being extracted and converted to UNICODE.public boolean isContentType(String expectedType)
expectedType - to be checked for content type.Copyright © 2020 CDAP Licensed under the Apache License, Version 2.0.