Class RequestHelper
- java.lang.Object
-
- com.helger.servlet.request.RequestHelper
-
@Immutable public final class RequestHelper extends Object
Misc. helper method onHttpServletRequestobjects.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTACHMENTContent-disposition value for file attachment.static StringDEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIXThe prefix to appended to the field name of the checkbox to create the hidden field.static StringFORM_DATAContent-disposition value for form data.static StringMULTIPARTPart of HTTP content type header.static StringMULTIPART_FORM_DATAHTTP content type header for multipart forms.static StringMULTIPART_MIXEDHTTP content type header for multiple uploads.static StringSERVLET_ATTR_CLIENT_CERTIFICATEstatic StringSERVLET_ATTR_SSL_CIPHER_SUITEstatic StringSERVLET_ATTR_SSL_KEY_SIZE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidforEachRequestHeader(jakarta.servlet.http.HttpServletRequest aHttpRequest, BiConsumer<String,String> aConsumer)Get a complete request header map as a copy.static com.helger.http.AcceptCharsetListgetAcceptCharsets(jakarta.servlet.http.HttpServletRequest aHttpRequest)static com.helger.http.AcceptEncodingListgetAcceptEncodings(jakarta.servlet.http.HttpServletRequest aHttpRequest)static com.helger.http.AcceptLanguageListgetAcceptLanguages(jakarta.servlet.http.HttpServletRequest aHttpRequest)static com.helger.http.AcceptMimeTypeListgetAcceptMimeTypes(jakarta.servlet.http.HttpServletRequest aHttpRequest)static com.helger.http.basicauth.BasicAuthClientCredentialsgetBasicAuthClientCredentials(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the Basic authentication credentials from the passed HTTP servlet request from the HTTP headerCHttpHeader.AUTHORIZATION.static StringgetCheckBoxHiddenFieldName(String sFieldName)Get the name of the automatic hidden field associated with a check-box.static longgetContentLength(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the content length of the passed request.static intgetDefaultServerPort(String sScheme)static com.helger.http.digestauth.DigestAuthClientCredentialsgetDigestAuthClientCredentials(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the Digest authentication credentials from the passed HTTP servlet request from the HTTP headerCHttpHeader.AUTHORIZATION.static StringBuildergetFullServerName(jakarta.servlet.http.HttpServletRequest aHttpRequest)static StringBuildergetFullServerName(String sScheme, String sServerName, int nServerPort)static StringgetFullServerNameAndPath(String sScheme, String sServerName, int nServerPort, String sPath, String sQueryString)static com.helger.commons.http.EHttpMethodgetHttpMethod(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the HTTP method associated with the given HTTP requeststatic com.helger.commons.http.EHttpMethodgetHttpMethodOrDefault(jakarta.servlet.http.HttpServletRequest aHttpRequest, com.helger.commons.http.EHttpMethod eDefault)Get the HTTP method associated with the given HTTP requeststatic StringgetHttpReferer(jakarta.servlet.http.HttpServletRequest aHttpRequest)static StringgetHttpUserAgentStringFromRequest(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the user agent from the given request.static com.helger.http.EHttpVersiongetHttpVersion(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the HTTP version associated with the given HTTP requeststatic StringgetPathInfo(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the request path info without an eventually appended session (";jsessionid=...")static StringgetPathWithinServlet(jakarta.servlet.http.HttpServletRequest aHttpRequest)Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.static StringgetPathWithinServlet(jakarta.servlet.http.HttpServletRequest aHttpRequest, boolean bUseEncodedPath)Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.static StringgetPathWithinServletContext(jakarta.servlet.http.HttpServletRequest aHttpRequest)Return the URI of the request within the servlet context.static StringgetPathWithinServletContext(jakarta.servlet.http.HttpServletRequest aHttpRequest, boolean bUseEncodedPath)Return the URI of the request within the servlet context.static X509Certificate[]getRequestClientCertificates(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the client certificates provided by a HTTP servlet request.static com.helger.commons.http.HttpHeaderMapgetRequestHeaderMap(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get a complete request header map as a copy.static IRequestParamMapgetRequestParamMap(jakarta.servlet.http.HttpServletRequest aHttpRequest)static StringgetRequestSSLCipherSuite(jakarta.servlet.http.HttpServletRequest aHttpRequest)static IntegergetRequestSSLKeySize(jakarta.servlet.http.HttpServletRequest aHttpRequest)static StringgetRequestURIDecoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the request URI without an eventually appended session (";jsessionid=...").
This method considers the GlobalWebScope custom context path.
This method returns the percent decoded parameters Examples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa:th.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?static StringgetRequestURIEncoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the request URI without an eventually appended session (";jsessionid=...").
This method considers the GlobalWebScope custom context path.
This method returns the percent encoded parameters "as is" Examples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa%3Ath.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?static StringBuildergetRequestURLDecoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Reconstructs the URL the client used to make the request.static StringBuildergetRequestURLEncoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Reconstructs the URL the client used to make the request.static intgetServerPortToUse(String sScheme, int nServerPort)static StringgetSessionID(com.helger.commons.url.ISimpleURL aURL)Get the session ID of the passed string (like in "test.html;JSESSIONID=1234").
Attention: this methods does not consider eventually present request parameters.static StringgetSessionID(String sValue)Get the session ID of the passed string (like in "test.html;JSESSIONID=1234").
Attention: this methods does not consider eventually present request parameters.static com.helger.useragent.uaprofile.UAProfilegetUAProfile(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the user agent object from the given HTTP request.static StringgetURIDecoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the full URI (excl. protocol) and parameters of the passed request.
Example:static StringgetURIEncoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the full URI (excl. protocol) and parameters of the passed request.
Example:static StringgetURLDecoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the full URL (incl. protocol) and parameters of the passed request.static StringgetURLEncoded(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the full URL (incl. protocol) and parameters of the passed request.static com.helger.useragent.IUserAgentgetUserAgent(jakarta.servlet.http.HttpServletRequest aHttpRequest)Get the user agent object from the given HTTP request.static com.helger.commons.url.SimpleURLgetWithoutSessionID(com.helger.commons.url.ISimpleURL aURL)Get the passed string without an eventually contained session ID like in "test.html;JSESSIONID=1234?static StringgetWithoutSessionID(String sValue)Get the passed string without an eventually contained session ID like in "test.html;JSESSIONID=1234".
Attention: this methods does not consider eventually present request parameters.static booleanisMultipartContent(jakarta.servlet.http.HttpServletRequest aHttpRequest)Utility method that determines whether the request contains multipart content.static booleanisMultipartContent(String sContentType)Utility method that determines whether the request contains multipart content.static booleanisMultipartFormDataContent(jakarta.servlet.http.HttpServletRequest aHttpRequest)Utility method that determines whether the request contains multipart content.static booleanisMultipartFormDataContent(String sContentType)Utility method that determines whether the request containsmultipart/form-datacontent.
-
-
-
Field Detail
-
SERVLET_ATTR_SSL_CIPHER_SUITE
public static final String SERVLET_ATTR_SSL_CIPHER_SUITE
- See Also:
- Constant Field Values
-
SERVLET_ATTR_SSL_KEY_SIZE
public static final String SERVLET_ATTR_SSL_KEY_SIZE
- See Also:
- Constant Field Values
-
SERVLET_ATTR_CLIENT_CERTIFICATE
public static final String SERVLET_ATTR_CLIENT_CERTIFICATE
- See Also:
- Constant Field Values
-
FORM_DATA
public static final String FORM_DATA
Content-disposition value for form data.- See Also:
- Constant Field Values
-
ATTACHMENT
public static final String ATTACHMENT
Content-disposition value for file attachment.- See Also:
- Constant Field Values
-
MULTIPART
public static final String MULTIPART
Part of HTTP content type header. Must be all lower case!- See Also:
- Constant Field Values
-
MULTIPART_FORM_DATA
public static final String MULTIPART_FORM_DATA
HTTP content type header for multipart forms. Must be all lower case!- See Also:
- Constant Field Values
-
MULTIPART_MIXED
public static final String MULTIPART_MIXED
HTTP content type header for multiple uploads. Must be all lower case!- See Also:
- Constant Field Values
-
DEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIX
public static final String DEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIX
The prefix to appended to the field name of the checkbox to create the hidden field.- See Also:
- Constant Field Values
-
-
Method Detail
-
getWithoutSessionID
@Nonnull public static String getWithoutSessionID(@Nonnull String sValue)
Get the passed string without an eventually contained session ID like in "test.html;JSESSIONID=1234".
Attention: this methods does not consider eventually present request parameters. If parameters are present, they are most likely be stripped away!- Parameters:
sValue- The value to strip the session ID from. May not benull.- Returns:
- The value without a session ID or the original string.
-
getWithoutSessionID
@Nonnull public static com.helger.commons.url.SimpleURL getWithoutSessionID(@Nonnull com.helger.commons.url.ISimpleURL aURL)
Get the passed string without an eventually contained session ID like in "test.html;JSESSIONID=1234?param=value".- Parameters:
aURL- The value to strip the session ID from the path- Returns:
- The value without a session ID or the original string.
-
getSessionID
@Nullable public static String getSessionID(@Nonnull String sValue)
Get the session ID of the passed string (like in "test.html;JSESSIONID=1234").
Attention: this methods does not consider eventually present request parameters. If parameters are present, they must be stripped away explicitly!- Parameters:
sValue- The value to get the session ID from. May not benull.- Returns:
- The session ID of the value or
nullif no session ID is present.
-
getSessionID
@Nullable public static String getSessionID(@Nonnull com.helger.commons.url.ISimpleURL aURL)
Get the session ID of the passed string (like in "test.html;JSESSIONID=1234").
Attention: this methods does not consider eventually present request parameters. If parameters are present, they must be stripped away explicitly!- Parameters:
aURL- The URL to get the session ID from. May not benull.- Returns:
- The session ID of the value or
nullif no session ID is present.
-
getRequestURIDecoded
@Nonnull public static String getRequestURIDecoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the request URI without an eventually appended session (";jsessionid=...").
This method considers the GlobalWebScope custom context path.
This method returns the percent decoded parametersExamples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa:th.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?a=b /xyz - Parameters:
aHttpRequest- The HTTP request. May not benull.- Returns:
- The request URI without the optional session ID. Never
null. - Since:
- 9.1.0
-
getRequestURIEncoded
@Nonnull public static String getRequestURIEncoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the request URI without an eventually appended session (";jsessionid=...").
This method considers the GlobalWebScope custom context path.
This method returns the percent encoded parameters "as is"Examples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa%3Ath.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?a=b /xyz - Parameters:
aHttpRequest- The HTTP request. May not benull.- Returns:
- The request URI without the optional session ID. Never
null. - Since:
- 9.1.0
-
getPathInfo
@Nullable public static String getPathInfo(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the request path info without an eventually appended session (";jsessionid=...")- Parameters:
aHttpRequest- The HTTP request- Returns:
- Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character. The optional session ID is stripped.
-
getPathWithinServletContext
@Nonnull public static String getPathWithinServletContext(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Return the URI of the request within the servlet context.- Parameters:
aHttpRequest- The HTTP request. May not benull.- Returns:
- the path within the web application and never
null. By default "/" is returned is an empty request URI is determined.
-
getPathWithinServletContext
@Nonnull public static String getPathWithinServletContext(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest, boolean bUseEncodedPath)
Return the URI of the request within the servlet context.- Parameters:
aHttpRequest- The HTTP request. May not benull.bUseEncodedPath-trueto use the URL encoded path,falseto use the decoded path- Returns:
- the path within the web application and never
null. By default "/" is returned is an empty request URI is determined. - Since:
- 9.1.10
-
getPathWithinServlet
@Nonnull public static String getPathWithinServlet(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.
Detects include request URL if called within a RequestDispatcher include.
E.g.: servlet mapping = "/test/*"; request URI = "/test/a" -> "/a".
E.g.: servlet mapping = "/test"; request URI = "/test" -> "".
E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".- Parameters:
aHttpRequest- current HTTP request- Returns:
- the path within the servlet mapping, or ""
-
getPathWithinServlet
@Nonnull public static String getPathWithinServlet(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest, boolean bUseEncodedPath)
Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.
Detects include request URL if called within a RequestDispatcher include.
E.g.: servlet mapping = "/test/*"; request URI = "/test/a" -> "/a".
E.g.: servlet mapping = "/test"; request URI = "/test" -> "".
E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".- Parameters:
aHttpRequest- current HTTP requestbUseEncodedPath-trueto use the URL encoded path,falseto use the decoded path- Returns:
- the path within the servlet mapping, or ""
- Since:
- 9.1.10
-
getRequestURLDecoded
@Nonnull @Nonempty public static StringBuilder getRequestURLDecoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
This method returns the percent decoded parametersIf this request has been forwarded using
RequestDispatcher.forward(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse), the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client.Because this method returns a
StringBuilder, not a string, you can modify the URL easily, for example, to append query parameters.This method is useful for creating redirect messages and for reporting errors.
- Parameters:
aHttpRequest- The HTTP request to get the request URL from. May not benull.- Returns:
- a
StringBuilderobject containing the reconstructed URL - Since:
- 9.1.10
-
getRequestURLEncoded
@Nonnull @Nonempty public static StringBuilder getRequestURLEncoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
This method returns the percent encoded parameters "as is"If this request has been forwarded using
RequestDispatcher.forward(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse), the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client.Because this method returns a
StringBuilder, not a string, you can modify the URL easily, for example, to append query parameters.This method is useful for creating redirect messages and for reporting errors.
- Parameters:
aHttpRequest- The HTTP request to get the request URL from. May not benull.- Returns:
- a
StringBuilderobject containing the reconstructed URL - Since:
- 9.1.10
-
getURLDecoded
@Nonnull @Nonempty public static String getURLDecoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the full URL (incl. protocol) and parameters of the passed request.
http://hostname.com/mywebapp/servlet/dir/a/b.xml=123?d=789
- Parameters:
aHttpRequest- The request to use. May not benull.- Returns:
- The full URL.
- Since:
- 9.1.10
- See Also:
getURI to retrieve the URL without the server scheme and name.
-
getURLEncoded
@Nonnull @Nonempty public static String getURLEncoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the full URL (incl. protocol) and parameters of the passed request.
http://hostname.com/mywebapp/servlet/dir/a/b.xml=123?d=789
- Parameters:
aHttpRequest- The request to use. May not benull.- Returns:
- The full URL.
- Since:
- 9.1.10
- See Also:
getURI to retrieve the URL without the server scheme and name.
-
getURIDecoded
@Nonnull @Nonempty public static String getURIDecoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the full URI (excl. protocol) and parameters of the passed request.
Example:/mywebapp/servlet/dir/a/b.xml=123?d=789
- Parameters:
aHttpRequest- The request to use. May not benull.- Returns:
- The full URI.
- Since:
- 9.1.10
- See Also:
getURL to retrieve the absolute URL
-
getURIEncoded
@Nonnull @Nonempty public static String getURIEncoded(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the full URI (excl. protocol) and parameters of the passed request.
Example:/mywebapp/servlet/dir/a/b.xml=123?d=789
- Parameters:
aHttpRequest- The request to use. May not benull.- Returns:
- The full URI.
- Since:
- 9.1.10
- See Also:
getURL to retrieve the absolute URL
-
getDefaultServerPort
@CheckForSigned public static int getDefaultServerPort(@Nullable String sScheme)
-
getServerPortToUse
@CheckForSigned public static int getServerPortToUse(@Nonnull String sScheme, @CheckForSigned int nServerPort)
-
getFullServerName
@Nonnull @Nonempty public static StringBuilder getFullServerName(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getFullServerName
@Nonnull @Nonempty public static StringBuilder getFullServerName(@Nullable String sScheme, @Nullable String sServerName, int nServerPort)
-
getFullServerNameAndPath
@Nonnull @Nonempty public static String getFullServerNameAndPath(@Nullable String sScheme, @Nullable String sServerName, int nServerPort, @Nullable String sPath, @Nullable String sQueryString)
-
getHttpReferer
@Nullable public static String getHttpReferer(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getHttpVersion
@Nullable public static com.helger.http.EHttpVersion getHttpVersion(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the HTTP version associated with the given HTTP request- Parameters:
aHttpRequest- The http request to query. May not benull.- Returns:
nullif no supported HTTP version is contained
-
getHttpMethod
@Nullable public static com.helger.commons.http.EHttpMethod getHttpMethod(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the HTTP method associated with the given HTTP request- Parameters:
aHttpRequest- The http request to query. May not benull.- Returns:
nullif no supported HTTP method is contained
-
getHttpMethodOrDefault
@Nullable public static com.helger.commons.http.EHttpMethod getHttpMethodOrDefault(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest, @Nullable com.helger.commons.http.EHttpMethod eDefault)
Get the HTTP method associated with the given HTTP request- Parameters:
aHttpRequest- The http request to query. May not benull.eDefault- The default to be returned, if no HTTP method could be found. May benull.- Returns:
nullif no supported HTTP method is contained- Since:
- 9.1.6
-
forEachRequestHeader
public static void forEachRequestHeader(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest, @Nonnull BiConsumer<String,String> aConsumer)
Get a complete request header map as a copy.- Parameters:
aHttpRequest- The source HTTP request. May not benull.aConsumer- The BiConsumer that takes name and value. May not benull.- Since:
- 9.1.9
-
getRequestHeaderMap
@Nonnull @ReturnsMutableCopy public static com.helger.commons.http.HttpHeaderMap getRequestHeaderMap(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get a complete request header map as a copy.- Parameters:
aHttpRequest- The source HTTP request. May not benull.- Returns:
- Never
null.
-
getRequestParamMap
@Nonnull public static IRequestParamMap getRequestParamMap(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getContentLength
@CheckForSigned public static long getContentLength(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the content length of the passed request. This is not done usingrequest.getContentLength()but instead parsing the HTTP header fieldCHttpHeader.CONTENT_LENGTHmanually!- Parameters:
aHttpRequest- Source HTTP request. May not benull.- Returns:
- -1 if no or an invalid content length is set in the header
-
getRequestSSLCipherSuite
@Nullable public static String getRequestSSLCipherSuite(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
- Parameters:
aHttpRequest- he HTTP servlet request to extract the information from. May not benull.- Returns:
- SSL cipher suite or
nullif no such attribute is present
-
getRequestSSLKeySize
@Nullable public static Integer getRequestSSLKeySize(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
- Parameters:
aHttpRequest- he HTTP servlet request to extract the information from. May not benull.- Returns:
- Bit size of the algorithm or
nullif no such attribute is present
-
getRequestClientCertificates
@Nullable public static X509Certificate[] getRequestClientCertificates(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the client certificates provided by a HTTP servlet request.- Parameters:
aHttpRequest- The HTTP servlet request to extract the information from. May not benull.- Returns:
nullif the passed request does not contain any client certificate
-
isMultipartContent
public static boolean isMultipartContent(@Nullable String sContentType)
Utility method that determines whether the request contains multipart content.- Parameters:
sContentType- The content type to be checked. May benull.- Returns:
trueif the request is multipart;falseotherwise.
-
isMultipartContent
public static boolean isMultipartContent(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Utility method that determines whether the request contains multipart content.- Parameters:
aHttpRequest- The servlet request to be evaluated. Must be non-null.- Returns:
trueif the request is multipart;falseotherwise.
-
isMultipartFormDataContent
public static boolean isMultipartFormDataContent(@Nullable String sContentType)
Utility method that determines whether the request containsmultipart/form-datacontent.- Parameters:
sContentType- The content type to be checked. May benull.- Returns:
trueif the passed, lowercased content type starts withmultipart/form-data;falseotherwise.
-
isMultipartFormDataContent
public static boolean isMultipartFormDataContent(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Utility method that determines whether the request contains multipart content.- Parameters:
aHttpRequest- The servlet request to be evaluated. Must be non-null.- Returns:
trueif the request is multipart;falseotherwise.
-
getAcceptCharsets
@Nonnull public static com.helger.http.AcceptCharsetList getAcceptCharsets(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getAcceptEncodings
@Nonnull public static com.helger.http.AcceptEncodingList getAcceptEncodings(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getAcceptLanguages
@Nonnull public static com.helger.http.AcceptLanguageList getAcceptLanguages(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getAcceptMimeTypes
@Nonnull public static com.helger.http.AcceptMimeTypeList getAcceptMimeTypes(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
-
getBasicAuthClientCredentials
@Nullable public static com.helger.http.basicauth.BasicAuthClientCredentials getBasicAuthClientCredentials(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the Basic authentication credentials from the passed HTTP servlet request from the HTTP headerCHttpHeader.AUTHORIZATION.- Parameters:
aHttpRequest- The HTTP request to be interpreted. May benull.- Returns:
nullif the passed request does not contain a valid HTTP Basic Authentication header value.
-
getDigestAuthClientCredentials
@Nullable public static com.helger.http.digestauth.DigestAuthClientCredentials getDigestAuthClientCredentials(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the Digest authentication credentials from the passed HTTP servlet request from the HTTP headerCHttpHeader.AUTHORIZATION.- Parameters:
aHttpRequest- The HTTP request to be interpreted. May benull.- Returns:
nullif the passed request does not contain a valid HTTP Digest Authentication header value.
-
getHttpUserAgentStringFromRequest
@Nullable public static String getHttpUserAgentStringFromRequest(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the user agent from the given request.- Parameters:
aHttpRequest- The HTTP request to get the UA from.- Returns:
nullif no user agent string is present
-
getUserAgent
@Nullable public static com.helger.useragent.IUserAgent getUserAgent(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the user agent object from the given HTTP request.- Parameters:
aHttpRequest- The HTTP request to extract the information from.- Returns:
- A non-
nulluser agent object ornullin case of an internal inconsistency.
-
getUAProfile
@Nonnull public static com.helger.useragent.uaprofile.UAProfile getUAProfile(@Nonnull jakarta.servlet.http.HttpServletRequest aHttpRequest)
Get the user agent object from the given HTTP request.- Parameters:
aHttpRequest- The HTTP request to extract the information from.- Returns:
- A non-
nulluser agent object.
-
getCheckBoxHiddenFieldName
@Nonnull @Nonempty public static String getCheckBoxHiddenFieldName(@Nonnull @Nonempty String sFieldName)
Get the name of the automatic hidden field associated with a check-box.- Parameters:
sFieldName- The name of the check-box.- Returns:
- The name of the hidden field associated with the given check-box name.
-
-