public class Headers
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCEPT |
static java.lang.String |
APPL_JAVASCRIPT |
static java.lang.String |
APPL_JSON |
static java.lang.String |
APPL_OCTET_STREAM |
static java.lang.String |
BINARY_TYPE |
static java.lang.String |
CONTENT_TYPE |
static java.lang.String |
CSS_TYPE |
static java.lang.String |
HTML_TYPE |
static java.lang.String |
IMAGE |
static java.lang.String |
IMAGE_TYPE |
static java.lang.String |
JSON_TYPE |
static java.lang.String |
MOZILLA_GENERIC_AGENT |
static java.lang.String |
SCRIPT_TYPE |
static java.lang.String |
TEXT_CSS |
static java.lang.String |
TEXT_HTML |
static java.lang.String |
TEXT_PLAIN |
static java.lang.String |
TEXT_TYPE |
static java.lang.String |
TEXT_XML |
static java.lang.String |
USER_AGENT |
static java.lang.String |
XML_TYPE |
Constructor and Description |
---|
Headers() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addHeadersForType(java.lang.String type,
java.lang.String headerStr)
Add one (or more) headers to the existing set of headers for the mapped type.
|
static java.lang.String |
appendHeaderValue(java.lang.String headers,
java.lang.String headerName,
java.lang.String headerValue)
Given a multi-line header String, append a header value to an existing header name,
or create the new header with the given value.
|
static java.lang.String |
convertHeadersMapToMultiLineString(java.util.Map<java.lang.String,java.lang.String> headerMap) |
static java.util.Map<java.lang.String,java.lang.String> |
convertHeadersMultiLineStringToMap(java.lang.String headers) |
static java.lang.String |
getBinaryHeaders()
Will lazily create the default headers for this type if they don't already exist.
|
static java.lang.String |
getCSSHeaders() |
static java.lang.String |
getHeadersForType(java.lang.String type)
Returns the headers currently set for a defined resource/request type
as a multi-line String.
|
(package private) static java.util.Map<java.lang.String,java.lang.String> |
getHeadersMapFromMultiLineString(java.lang.String headers)
Utility method to convert headers multi-line string to a Map
|
static java.lang.String |
getHtmlHeaders() |
static java.lang.String |
getImageHeaders() |
static java.lang.String |
getJSONHeaders() |
static java.lang.String |
getScriptHeaders() |
static java.lang.String |
getTextHeaders() |
static java.lang.String |
getXMLHeaders() |
static void |
loadHeaders(RuntimeDataInterface runtime,
java.lang.String headersFile,
java.lang.String method,
java.lang.String type) |
static java.lang.String |
removeHeadersForType(java.lang.String type,
java.lang.String headerStr)
Remove one (or more) header(s) from the existing headers for the mapped type.
|
static java.lang.String |
removeHeaderValue(java.lang.String headers,
java.lang.String headerName,
java.lang.String headerValue)
Given a multi-line header String, remove a header value from an existing header name,
or create the new header without the given value.
|
static void |
resetHeaders() |
static void |
setBinaryHeaders(java.lang.String _binaryHeaders) |
static void |
setCSSHeaders(java.lang.String _cssHeaders) |
static void |
setHeadersForType(java.lang.String type,
java.lang.String headerStr)
Wholesale set/replace the headers multi-line String to be used for a
predefined or custom resource/request type.
|
static void |
setHtmlHeaders(java.lang.String _htmlHeaders) |
static void |
setImageHeaders(java.lang.String _imageHeaders) |
static void |
setJSONHeaders(java.lang.String _jsonHeaders) |
static void |
setScriptHeaders(java.lang.String _scriptHeaders) |
static void |
setTextHeaders(java.lang.String _textHeaders) |
static void |
setXMLHeaders(java.lang.String _xmlHeaders) |
public static final java.lang.String BINARY_TYPE
public static final java.lang.String JSON_TYPE
public static final java.lang.String TEXT_TYPE
public static final java.lang.String XML_TYPE
public static final java.lang.String HTML_TYPE
public static final java.lang.String IMAGE_TYPE
public static final java.lang.String CSS_TYPE
public static final java.lang.String SCRIPT_TYPE
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String ACCEPT
public static final java.lang.String USER_AGENT
public static final java.lang.String APPL_OCTET_STREAM
public static final java.lang.String APPL_JSON
public static final java.lang.String TEXT_PLAIN
public static final java.lang.String TEXT_XML
public static final java.lang.String TEXT_HTML
public static final java.lang.String IMAGE
public static final java.lang.String TEXT_CSS
public static final java.lang.String APPL_JAVASCRIPT
public static final java.lang.String MOZILLA_GENERIC_AGENT
public static java.lang.String getHeadersForType(java.lang.String type)
There are predefined request resource/request headers that can be retrieved and even changed. The user is also able to retrieve custom headers previously stored using a custom type.
Ex:
type
- #setHeadersForType(String,Collection)
,
#addHeaderForType(String, String)
,
#removeHeaderForType(String, String)
public static void setHeadersForType(java.lang.String type, java.lang.String headerStr)
type
- headerStr
- Multi-line String containing the HTTP header(s)java.io.IOException
org.apache.hc.core5.http.HttpException
getHeadersForType(String)
,
#addHeaderForType(String, String)
,
#removeHeaderForType(String, String)
public static java.lang.String addHeadersForType(java.lang.String type, java.lang.String headerStr)
type
- headerStr
- Multi-line String containing the HTTP headersjava.io.IOException
org.apache.hc.core5.http.HttpException
setHeadersForType(String,String)
,
getHeadersForType(String)
,
#removeHeaderForType(String, String)
public static java.lang.String removeHeadersForType(java.lang.String type, java.lang.String headerStr)
type
- headerStr
- Multi-line String containing the HTTP header(s)java.io.IOException
org.apache.hc.core5.http.HttpException
#setHeadersForType(String,Collection)
,
getHeadersForType(String)
,
#addHeaderForType(String, String)
public static java.lang.String getBinaryHeaders()
#setBinaryHeaders(Collection)
public static void setBinaryHeaders(java.lang.String _binaryHeaders)
_binaryHeaders
- the _binaryHeaders to set for all future requests for Binary resources.getBinaryHeaders()
public static java.lang.String getJSONHeaders()
#setJSONHeaders(Collection)
public static void setJSONHeaders(java.lang.String _jsonHeaders)
_jsonHeaders
- the _jsonHeaders to set for all future requests for JSON resources.getJSONHeaders()
public static java.lang.String getTextHeaders()
#setTextHeaders(Collection)
public static void setTextHeaders(java.lang.String _textHeaders)
_textHeaders
- the _textHeaders to set for all future requests for Text resources.getTextHeaders()
public static java.lang.String getXMLHeaders()
#setXMLHeaders(Collection)
public static void setXMLHeaders(java.lang.String _xmlHeaders)
_xmlHeaders
- the _xmlHeaders to set for all future requests for XML resources.getXMLHeaders()
public static java.lang.String getHtmlHeaders()
#setHtmlHeaders(Collection)
public static void setHtmlHeaders(java.lang.String _htmlHeaders)
_htmlHeaders
- the _htmlHeaders to set for all future requests for Html resources.getHtmlHeaders()
public static java.lang.String getImageHeaders()
#setImageHeaders(Collection)
public static void setImageHeaders(java.lang.String _imageHeaders)
_imageHeaders
- the _imageHeaders to set for all future requests for Image resources.getImageHeaders()
public static java.lang.String getCSSHeaders()
#setCSSHeaders(Collection)
public static void setCSSHeaders(java.lang.String _cssHeaders)
_cssHeaders
- the _cssHeaders to set for all future requests for CSS resources.getCSSHeaders()
public static java.lang.String getScriptHeaders()
#setScriptHeaders(Collection)
public static void setScriptHeaders(java.lang.String _scriptHeaders)
_scriptHeaders
- the _scriptHeaders to set for all future requests for Script resources.getScriptHeaders()
public static java.lang.String convertHeadersMapToMultiLineString(java.util.Map<java.lang.String,java.lang.String> headerMap)
public static java.util.Map<java.lang.String,java.lang.String> convertHeadersMultiLineStringToMap(java.lang.String headers)
static java.util.Map<java.lang.String,java.lang.String> getHeadersMapFromMultiLineString(java.lang.String headers)
headers
- Multi-line String containing complete header infopublic static java.lang.String appendHeaderValue(java.lang.String headers, java.lang.String headerName, java.lang.String headerValue)
Example: appendHeaderValue(headers, "Accept", "text/html");
This does NOT act on prestored headers, only the header String provided.
When appending, this routine will prefix the value with a separator.
headers
- multi-line header string.headerName
- name of the header to be created or appended.headerValue
- value to add to the provided header name.public static java.lang.String removeHeaderValue(java.lang.String headers, java.lang.String headerName, java.lang.String headerValue)
Example: removeHeaderValue(headers, "Accept", "text/html");
This does NOT act on prestored headers, only the header String provided.
When removing, this routine will attempt to fix any separators.
headers
- multi-line header string.headerName
- name of the header to have a value removed.headerValue
- value to remove.public static void loadHeaders(RuntimeDataInterface runtime, java.lang.String headersFile, java.lang.String method, java.lang.String type) throws SAFSException
SAFSException
public static void resetHeaders()
Copyright © SAS Institute. All Rights Reserved.