public abstract class HttpHeader extends Object implements Serializable
Constructor and Description |
---|
HttpHeader() |
HttpHeader(String data)
Construct a HttpHeader from a given String.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String name,
String val)
Add a header with the name and value given.
|
void |
clear() |
String |
getCharset() |
int |
getContentLength()
Get the content length of this header.
|
String |
getHeader(String name)
Get the first header value using the name given.
|
List<HttpHeaderField> |
getHeaders() |
Vector<String> |
getHeaders(String name)
Deprecated.
since 2.9.0. See
getHeaderValues(String) instead |
String |
getHeadersAsString()
Get the headers as string.
|
List<String> |
getHeaderValues(String name)
Get header(s) with the name.
|
String |
getLineDelimiter()
Get the line delimiter of this header.
|
String |
getNormalisedContentTypeValue()
Gets the normalised value of the (first)
Content-Type header. |
abstract String |
getPrimeHeader()
Get the prime header.
|
String |
getVersion()
Return the HTTP version (e.g.
|
boolean |
hasContentType(String... contentTypes)
Tells whether or not the HTTP header contains any of the given
Content-Type values. |
boolean |
isConnectionClose()
Check if this header expect connection to be closed.
|
boolean |
isEmpty()
Tells whether or not the header is empty.
|
boolean |
isHttp10()
Check if this header is HTTP 1.0.
|
boolean |
isHttp11()
Check if this header is HTTP 1.1.
|
boolean |
isImage()
Get if this is a image header.
|
boolean |
isMalformedHeader()
Get if this is a malformed header.
|
boolean |
isText()
Get if this is a text header.
|
boolean |
isTransferEncodingChunked()
Check if Transfer Encoding Chunked is set in this header.
|
protected boolean |
parse(String data)
Parse this Http header using the String given.
|
void |
setContentLength(int len)
Set the content length of this header.
|
void |
setHeader(String name,
String value)
Set a header name and value.
|
void |
setMessage(String data)
Set and parse this HTTP header with the string given.
|
abstract void |
setVersion(String version)
Set the HTTP version of this header.
|
String |
toString()
Get a string representation of this header.
|
public static final String CRLF
public static final String LF
public static final String CONTENT_LENGTH
public static final String TRANSFER_ENCODING
public static final String CONTENT_ENCODING
public static final String CONTENT_TYPE
public static final String PROXY_CONNECTION
public static final String PROXY_AUTHENTICATE
public static final String CONNECTION
public static final String AUTHORIZATION
public static final String WWW_AUTHENTICATE
public static final String LOCATION
public static final String IF_MODIFIED_SINCE
public static final String IF_NONE_MATCH
public static final String USER_AGENT
public static final String ACCEPT_ENCODING
public static final String CACHE_CONTROL
public static final String PRAGMA
public static final String REFERER
public static final String X_ZAP_REQUESTID
public static final String X_SECURITY_PROXY
public static final String COOKIE
public static final String SET_COOKIE
public static final String SET_COOKIE2
public static final String X_XSS_PROTECTION
public static final String X_FRAME_OPTION
public static final String X_CONTENT_TYPE_OPTIONS
public static final String HTTP09
public static final String HTTP10
public static final String HTTP11
public static final String _CLOSE
public static final String _KEEP_ALIVE
public static final String _CHUNKED
public static final String FORM_URLENCODED_CONTENT_TYPE
public static final String JSON_CONTENT_TYPE
public static final String SCHEME_HTTP
public static final String SCHEME_HTTPS
public static final String HTTP
public static final String HTTPS
public static final String DEFLATE
public static final String GZIP
public static final String IDENTITY
public static final String SEC_PROXY_INTERCEPT
public static final String SEC_PROXY_RECORD
public static final Pattern patternCRLF
public static final Pattern patternLF
protected static final String p_TEXT
protected static final String p_METHOD
protected static final String p_SP
protected static final String p_URI
protected static final String p_VERSION
protected static final String p_STATUS_CODE
protected static final String p_REASON_PHRASE
protected String mStartLine
protected String mMsgHeader
protected boolean mMalformedHeader
protected int mContentLength
protected String mLineDelimiter
protected String mVersion
public static final String ACCESS_CONTROL_ALLOW_ORIGIN
public static final String ACCESS_CONTROL_ALLOW_HEADERS
public static final String ACCESS_CONTROL_ALLOW_METHODS
public static final String ACCESS_CONTROL_EXPOSE_HEADERS
public static final String METHODS_ALLOW
public static final String METHODS_PUBLIC
public static final String X_ZAP_SCAN_ID
public static final String X_ZAP_API_KEY
public static final String X_ZAP_API_NONCE
public static final String PROXY_AUTHORIZATION
public static final String X_CSRF_TOKEN
public static final String X_CSRFTOKEN
public static final String X_XSRF_TOKEN
public HttpHeader()
public HttpHeader(String data) throws HttpMalformedHeaderException
data
- HttpMalformedHeaderException
public void setMessage(String data) throws HttpMalformedHeaderException
data
- HttpMalformedHeaderException
public void clear()
public String getHeader(String name)
name
- @Deprecated public Vector<String> getHeaders(String name)
getHeaderValues(String)
insteadname
- public List<String> getHeaderValues(String name)
name
- the name of the header(s) to return.List
holding the value(s) as String(s).public List<HttpHeaderField> getHeaders()
public void addHeader(String name, String val)
name
- val
- public void setHeader(String name, String value)
name
- value
- public String getVersion()
public abstract void setVersion(String version)
version
- public int getContentLength()
public void setContentLength(int len)
len
- public boolean isConnectionClose()
public boolean isHttp10()
public boolean isHttp11()
public boolean isTransferEncodingChunked()
protected boolean parse(String data) throws Exception
data
- String to be parsed to form this header.Exception
public boolean isMalformedHeader()
public String toString()
public abstract String getPrimeHeader()
public boolean isImage()
public boolean isText()
public boolean hasContentType(String... contentTypes)
Content-Type
values.
The values are expected to be in lower case.
contentTypes
- the values to check.true
if any of the given values is contained in the (first) Content-Type
header, false
otherwise.getNormalisedContentTypeValue()
public String getNormalisedContentTypeValue()
Content-Type
header.
The normalisation is done by changing all characters to lower case.
null
.hasContentType(String...)
public String getLineDelimiter()
public String getHeadersAsString()
public boolean isEmpty()
A header is empty if it has no content (for example, no start line nor headers).
true
if the header is empty, false
otherwise.public String getCharset()