public class HttpRequestHeader extends HttpHeader
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPT
The
Accept request header. |
static String |
CONNECT |
static String |
DELETE |
static String |
GET |
static String |
HEAD |
static String |
HOST |
static String[] |
METHODS |
static String |
OPTIONS |
static String |
ORIGIN
The
Origin request header. |
static String |
PATCH |
static String |
POST |
static String |
PUT |
static String |
TRACE |
static String |
TRACK |
_CHUNKED, _CLOSE, _KEEP_ALIVE, ACCEPT_ENCODING, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, COOKIE, CRLF, DEFLATE, FORM_URLENCODED_CONTENT_TYPE, GZIP, HTTP, HTTP09, HTTP10, HTTP11, HTTPS, IDENTITY, IF_MODIFIED_SINCE, IF_NONE_MATCH, JSON_CONTENT_TYPE, LF, LOCATION, mContentLength, METHODS_ALLOW, METHODS_PUBLIC, mHeaderFields, mLineDelimiter, mMalformedHeader, mMsgHeader, mStartLine, mVersion, p_METHOD, p_REASON_PHRASE, p_SP, p_STATUS_CODE, p_TEXT, p_URI, p_VERSION, patternCRLF, patternLF, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, PROXY_CONNECTION, REFERER, SCHEME_HTTP, SCHEME_HTTPS, SEC_PROXY_INTERCEPT, SEC_PROXY_RECORD, SET_COOKIE, SET_COOKIE2, TRANSFER_ENCODING, USER_AGENT, WWW_AUTHENTICATE, X_CONTENT_TYPE_OPTIONS, X_CSRF_TOKEN, X_CSRFTOKEN, X_FRAME_OPTION, X_SECURITY_PROXY, X_XSRF_TOKEN, X_XSS_PROTECTION, X_ZAP_API_KEY, X_ZAP_API_NONCE, X_ZAP_REQUESTID, X_ZAP_SCAN_ID
Constructor and Description |
---|
HttpRequestHeader()
Constructor for an empty header.
|
HttpRequestHeader(String data)
Constructor of a request header with the string.
|
HttpRequestHeader(String data,
boolean isSecure)
Constructor of a request header with the string.
|
HttpRequestHeader(String method,
org.apache.commons.httpclient.URI uri,
String version)
Constructs a
HttpRequestHeader with the given method, URI, and version. |
HttpRequestHeader(String method,
org.apache.commons.httpclient.URI uri,
String version,
ConnectionParam params)
Deprecated.
(2.8.0) Use
HttpRequestHeader(String, URI, String) instead. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
int |
getContentLength()
Get the content length in this request header.
|
TreeSet<HtmlParameter> |
getCookieParams() |
static String |
getDefaultUserAgent()
Gets the user agent used by
default request
header . |
String |
getHostName()
Get the host name in this request header.
|
int |
getHostPort()
Gets the host port number of this request message, a non-negative integer.
|
List<HttpCookie> |
getHttpCookies()
Gets a list of the http cookies from this request Header.
|
String |
getMethod()
Get the HTTP method (GET, POST ...
|
String |
getPrimeHeader()
Return the prime header (first line).
|
boolean |
getSecure()
Deprecated.
Replaced by
isSecure() . It will be removed in a future release. |
InetAddress |
getSenderAddress()
Gets the senders IP address
|
org.apache.commons.httpclient.URI |
getURI()
Get the URI of this request header.
|
boolean |
isImage()
Return if this request header is a image request basing on the path suffix.
|
static boolean |
isRequestLine(String data)
Return if the data given is a request header basing on the first start line.
|
boolean |
isSecure()
Tells whether the request is secure, or not.
|
static org.apache.commons.httpclient.URI |
parseURI(String sUri) |
void |
setCookieParams(TreeSet<HtmlParameter> cookieParams) |
void |
setCookies(List<HttpCookie> cookies)
Construct new "Cookie:" line in request header based on HttpCookies.
|
static void |
setDefaultUserAgent(String defaultUserAgent)
Sets the user agent used by
default request
header . |
void |
setGetParams(TreeSet<HtmlParameter> getParams) |
void |
setMessage(String data)
Set this request header with the given message.
|
void |
setMessage(String data,
boolean isSecure)
Set this request header with the given message.
|
void |
setMethod(String method)
Set the HTTP method of this request header.
|
void |
setSecure(boolean isSecure)
Sets whether or not the request is done using a secure scheme, HTTPS.
|
void |
setSenderAddress(InetAddress inetAddress)
Sets the senders IP address.
|
void |
setURI(org.apache.commons.httpclient.URI uri)
Sets the URI of this request header.
|
void |
setVersion(String version)
Set the HTTP version of this request header.
|
addHeader, getCharset, getHeader, getHeaders, getHeaders, getHeadersAsString, getLineDelimiter, getNormalisedContentTypeValue, getVersion, hasContentType, isConnectionClose, isEmpty, isHttp10, isHttp11, isMalformedHeader, isText, isTransferEncodingChunked, parse, setContentLength, setHeader, toString
public static final String ACCEPT
Accept
request header.public static final String ORIGIN
Origin
request header.public static final String CONNECT
public static final String DELETE
public static final String GET
public static final String HEAD
public static final String OPTIONS
public static final String PATCH
public static final String POST
public static final String PUT
public static final String TRACE
public static final String TRACK
public static final String[] METHODS
public static final String HOST
public HttpRequestHeader()
public HttpRequestHeader(String data, boolean isSecure) throws HttpMalformedHeaderException
data
- the request headerisSecure
- true
if the request should be secure, false
otherwiseHttpMalformedHeaderException
- if the request being set is malformedsetSecure(boolean)
public HttpRequestHeader(String data) throws HttpMalformedHeaderException
data
- the request headerHttpMalformedHeaderException
- if the request being set is malformedpublic HttpRequestHeader(String method, org.apache.commons.httpclient.URI uri, String version) throws HttpMalformedHeaderException
HttpRequestHeader
with the given method, URI, and version.
The following headers are automatically added:
Host
, with the domain and port from the given URI.
User-Agent
, using the getDefaultUserAgent()
.
Pragma: no-cache
Cache-Control: no-cache
, if version is HTTP/1.1
Content-Type: application/x-www-form-urlencoded
, if the method is POST or PUT.
method
- the request method.uri
- the request target.version
- the version, for example, HTTP/1.1
.HttpMalformedHeaderException
- if the resulting HTTP header is malformed.@Deprecated public HttpRequestHeader(String method, org.apache.commons.httpclient.URI uri, String version, ConnectionParam params) throws HttpMalformedHeaderException
HttpRequestHeader(String, URI, String)
instead.HttpRequestHeader
with the given method, URI, and version.
The following headers are automatically added:
Host
, with the domain and port from the given URI.
User-Agent
, using the getDefaultUserAgent()
.
Pragma: no-cache
Cache-Control: no-cache
, if version is HTTP/1.1
Content-Type: application/x-www-form-urlencoded
, if the method is POST or PUT.
method
- the request method.uri
- the request target.version
- the version, for example, HTTP/1.1
.params
- unused.HttpMalformedHeaderException
- if the resulting HTTP header is malformed.public void clear()
clear
in class HttpHeader
public void setMessage(String data, boolean isSecure) throws HttpMalformedHeaderException
data
- the request headerisSecure
- true
if the request should be secure, false
otherwiseHttpMalformedHeaderException
- if the request being set is malformedsetSecure(boolean)
public void setMessage(String data) throws HttpMalformedHeaderException
setMessage
in class HttpHeader
HttpMalformedHeaderException
public String getMethod()
public void setMethod(String method)
method
- the new method, must not be null
.public org.apache.commons.httpclient.URI getURI()
public void setURI(org.apache.commons.httpclient.URI uri) throws org.apache.commons.httpclient.URIException
uri
- the new request URIorg.apache.commons.httpclient.URIException
- if an error occurred while setting the request URI@Deprecated public boolean getSecure()
isSecure()
. It will be removed in a future release.true
if the request is secure, false
otherwisepublic boolean isSecure()
true
if the request is secure, false
otherwise.public void setSecure(boolean isSecure) throws org.apache.commons.httpclient.URIException
isSecure
- true
if the request should be secure, false
otherwiseorg.apache.commons.httpclient.URIException
- if an error occurred while rebuilding the request URIpublic void setVersion(String version)
setVersion
in class HttpHeader
public int getContentLength()
getContentLength
in class HttpHeader
public String getHostName()
public int getHostPort()
If no port is defined the default port for the used scheme will be returned, either 80 for HTTP or 443 for HTTPS.
public boolean isImage()
isImage
in class HttpHeader
public static boolean isRequestLine(String data)
data
- the data to be checkedtrue
if the data contains a request line, false
otherwise.public String getPrimeHeader()
getPrimeHeader
in class HttpHeader
public static org.apache.commons.httpclient.URI parseURI(String sUri) throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIException
public void setGetParams(TreeSet<HtmlParameter> getParams)
public void setCookies(List<HttpCookie> cookies)
cookies
- the new cookiespublic void setCookieParams(TreeSet<HtmlParameter> cookieParams)
public TreeSet<HtmlParameter> getCookieParams()
public List<HttpCookie> getHttpCookies()
IllegalArgumentException
- if a problem is encountered while processing the "Cookie: "
header line.public void setSenderAddress(InetAddress inetAddress)
inetAddress
- the senders IP addresspublic InetAddress getSenderAddress()
public static void setDefaultUserAgent(String defaultUserAgent)
default request
header
.
This is expected to be called only by core code, when the corresponding option is changed.
defaultUserAgent
- the default user agent.public static String getDefaultUserAgent()
default request
header
.