public class WebUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
WebUtil.ParameterFilter
Query string parameters filter
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_WEB_DATE_FORMAT |
static java.lang.String |
FRAGMENT_ID_PARAM |
static java.lang.String |
GUEST_AUTH_PREFIX |
static java.lang.String |
HTTP_AUTH_PREFIX |
static java.lang.String |
TC_SKIP_LOG_SESSION_MARKER |
Modifier and Type | Method and Description |
---|---|
static void |
addCacheHeadersForIE(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Fixes IE problem when it cannot download files over https (see TW-9821).
|
static java.lang.String |
combineContextPath(java.lang.String prefixPath,
java.lang.String path)
Combines two path with prefix with regard to starting and trailing slashes.
|
static javax.servlet.http.Cookie |
createCookie(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.String value,
int age)
Creates a cookie with specified age
|
static java.lang.String |
createPathWithParameters(javax.servlet.http.HttpServletRequest request)
Same as
createPathWithParameters(javax.servlet.http.HttpServletRequest, jetbrains.buildServer.web.util.WebUtil.ParameterFilter)
with default filter which accepts all parameters. |
static java.lang.String |
createPathWithParameters(javax.servlet.http.HttpServletRequest request,
WebUtil.ParameterFilter filter)
From specified request creates part of the URL which contains path and query string.
|
static java.lang.String |
createRequestParameters(javax.servlet.http.HttpServletRequest request)
Generate list of all requests parameters, i.e.
|
static java.lang.String |
createRequestParameters(javax.servlet.http.HttpServletRequest request,
WebUtil.ParameterFilter filter)
Generate list of all requests parameters, i.e.
|
static java.lang.String |
createRequestWithoutInit(javax.servlet.http.HttpServletRequest request)
Creates a new URL with all request parameters, except "init=1", if present.
|
static javax.servlet.http.Cookie |
createSessionCookie(javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.String value)
Creates session cookie (such cookie will be removed when browser exits).
|
static java.lang.String |
decode(java.lang.String string)
Deprecated.
|
static void |
dumpRequest(javax.servlet.http.HttpServletRequest request,
java.io.PrintStream out)
Dumps request information to the specified print stream
|
static java.lang.String |
encode(java.lang.String string)
Deprecated.
|
static java.lang.String |
escapeForJavaScript(java.lang.String text,
boolean removeLineFeeds,
boolean forHTMLAttribute)
Escapes text so that it can be used in JavaScript string.
|
static java.lang.String |
escapeForJavaScriptIdentifier(java.lang.String text)
Escapes string to be a javascript identifier
|
static java.lang.String |
escapeUrlForQuotes(java.lang.String url)
Fixes security issues related to passing the URLs (or URL parts) to the quoted context as is.
|
static java.lang.String |
escapeXml(java.lang.String text)
Replaces some characters like < > and others in the text with corresponding XML entities.
|
static boolean |
experimentalUIAvailable() |
static boolean |
experimentalUIToggleEnabled(javax.servlet.http.HttpServletRequest request)
Deprecated.
experimental features are only used on dedicated pages, see withExperimentalOverview
|
static java.lang.String |
findRefererInRequest(javax.servlet.http.HttpServletRequest request)
Returns the request referrer (
"REFERER" or "HTTP_REFERER" header). |
static java.lang.String |
firstLine(java.lang.String text)
Return first line of a multiline text.
|
static java.lang.String |
getContentDispositionValue(javax.servlet.http.HttpServletRequest request,
java.lang.String type,
java.lang.String fileName)
Returns a proper
Content-Disposition value based on the type ("inline", "attachment")
and current request . |
static java.lang.String |
getDeepestRequestUrl(javax.servlet.http.HttpServletRequest request)
Returns currently processing request path with respect to servlet includes
|
static int |
getDefaultPort(java.lang.String scheme)
Returns a default port according to the request schema.
|
static java.lang.String |
getFilename(SBuild build)
Create filename candidate from build information, including project name and build type name and build number
|
static java.lang.String |
getHeaderDump(javax.servlet.http.HttpServletRequest request,
java.lang.String headerName)
Get string representation of the specified header in the form 'name : value'.
|
static java.lang.String |
getLoggableSessionId(java.lang.String httpSessionId) |
static int |
getMaxUiTestLimit() |
static java.lang.String |
getMimeType(javax.servlet.http.HttpServletRequest request,
java.lang.String relativePath)
Deprecated.
use
getMimeType(HttpServletRequest, String, boolean) instead |
static java.lang.String |
getMimeType(javax.servlet.http.HttpServletRequest request,
java.lang.String relativePath,
boolean safeMode)
Computes MIME type for the file located by the specified relative path.
|
static java.lang.String |
getOriginalPathWithoutAuthenticationType(javax.servlet.http.HttpServletRequest request)
Returns original path without authentication types.
|
static java.lang.String |
getOriginalPathWithoutContext(javax.servlet.http.HttpServletRequest request)
Returns path part of the request URL without context path.
|
static java.lang.String |
getOriginalRequestUrl(javax.servlet.http.HttpServletRequest request)
Returns the approximation of the URI including path and query string (and excluding protocol, host and port)
for the original HTTP request received by TeamCity.
|
static java.lang.StringBuilder |
getOriginUrl(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
getPathFromUrl(java.lang.String url)
Return path without session id and parameters
|
static java.lang.String |
getPathWithoutAuthenticationType(javax.servlet.http.HttpServletRequest request)
Returns path without context and TeamCity specific authentication types, like httpAuth or guestAuth prefixes.
|
static java.lang.String |
getPathWithoutAuthenticationType(java.lang.String path)
Returns path without context and TeamCity specific authentication types, like httpAuth or guestAuth prefixes.
|
static java.lang.String |
getPathWithoutContext(javax.servlet.http.HttpServletRequest request)
Returns path part of the request URL without context path.
|
static java.lang.String |
getPathWithoutContext(javax.servlet.http.HttpServletRequest request,
java.lang.String reqURI)
Returns path part of the request URL without context path.
|
static java.lang.String |
getRemoteAddress(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
getRequestDump(javax.servlet.http.HttpServletRequest request)
Returns debug representation of a request as string suitable for logging.
|
static java.lang.String |
getRequestUrl(javax.servlet.http.HttpServletRequest request)
Returns the URL used in
request |
static java.lang.String |
getRequestUrl(java.lang.String requestURI,
javax.servlet.http.HttpServletRequest request)
Returns the URL used in
request |
static java.lang.String |
getRootUrl(javax.servlet.http.HttpServletRequest request)
Reconstructs root URL from the specified request.
|
static java.lang.String |
getScheme(javax.servlet.http.HttpServletRequest request)
Returns a schema for request.
|
static java.lang.String |
getServerName(javax.servlet.http.HttpServletRequest request)
Returns a server hostname for request.
|
static int |
getServerPort(javax.servlet.http.HttpServletRequest request)
Returns a server port for request.
|
static javax.servlet.ServletContext |
getServletContext(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
getShortRequestDescription(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
getUserAgent(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
hostAndPort(java.lang.String ipOrHost,
java.lang.Integer portNumber) |
static boolean |
isAbsolute(java.lang.String url)
Returns true if url is not relative, i.e.
|
static boolean |
isAjaxRequest(javax.servlet.http.HttpServletRequest request)
Checks if request is AJAX request
|
static boolean |
isCommonExternalError(java.lang.Throwable e) |
static boolean |
isExperimentalUIOptional() |
static boolean |
isForward(javax.servlet.http.HttpServletRequest request)
True if request is being forwarded to another resource
|
static boolean |
isIE(javax.servlet.http.HttpServletRequest request)
Returns true if the request's client is IE
|
static boolean |
isIE10OrLower(javax.servlet.http.HttpServletRequest request)
Returns true if the request's client is IE <= 10.
|
static boolean |
isInclude(javax.servlet.http.HttpServletRequest request)
True if our resource is being included by another controller.
|
static boolean |
isJspPath(java.lang.String path)
Returns true if the specified path taken from the HTTP request points to JSP
|
static boolean |
isJspPrecompilationRequest(javax.servlet.http.HttpServletRequest request) |
static boolean |
isPageFragmentRequest(javax.servlet.http.HttpServletRequest request)
Returns true if request is about to serve page fragment.
|
static boolean |
isProbablyBrowser(javax.servlet.http.HttpServletRequest request)
Returns true if user agent header specified in the request indicates that request was
sent from a commonly known browser
|
static boolean |
isReactUISupportAware(javax.servlet.http.HttpServletRequest request)
Deprecated.
react is used in all supported browsers
|
static boolean |
isSafari(javax.servlet.http.HttpServletRequest request)
Returns true if the request's client is Safari.
|
static boolean |
isSecure(javax.servlet.http.HttpServletRequest request)
Returns true if the original request was made using https:// protocol, considers proxy-added headers for the detection
|
static boolean |
isStandardPort(int port,
boolean isHttps) |
static boolean |
isWebComponentSupportAware(javax.servlet.http.HttpServletRequest request) |
static boolean |
isWebSocketUpgradeRequest(javax.servlet.http.HttpServletRequest request)
Checks whether request is a HTTP upgrade to websocket
|
static void |
logRequestWarn(java.lang.String message,
java.lang.Exception e,
javax.servlet.http.HttpServletRequest request,
com.intellij.openapi.diagnostic.Logger log)
Logs warning that occurred during request processing.
|
static java.lang.String |
makeBreakable(java.lang.String source,
java.lang.String regexp,
boolean escape)
Makes the text breakable in HTML by replacing some places of the string with <wbr/> tags .
|
static void |
notFound(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String errorString,
com.intellij.openapi.diagnostic.Logger log)
Generates 404 Not Found response and logs specified message into the specified logger
|
static void |
preventCaching(javax.servlet.http.HttpServletResponse response)
Prevent the response from being cached.
|
static java.lang.String |
removeSessionId(java.lang.String uri) |
static java.lang.String |
replace(java.lang.String text,
java.util.regex.Matcher matcher,
java.util.function.Function<java.lang.String,java.lang.String> nonMatched,
java.util.function.Function<java.util.regex.Matcher,java.lang.String> matched) |
static java.lang.String |
replace(java.lang.String text,
java.util.regex.Pattern pattern,
java.util.function.Function<java.lang.String,java.lang.String> nonMatched,
java.util.function.Function<java.util.regex.Matcher,java.lang.String> matched)
Performs replacement allowing proper escaping for all text parts
Similar to Matcher.appendReplacement(StringBuffer, String) and Matcher.appendTail(StringBuffer) yet allows to perform changes on all text parts. |
static boolean |
requirePostMethodFail(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
If request is not POST, send 405 status to response stream.
|
static void |
sendErrorPlain(javax.servlet.http.HttpServletResponse response,
int statusCode,
java.lang.String text)
Sends error response with given statusCode and text message regarding the reason, in text/plain format (for better reading from console)
|
static void |
sendForbiddenPlain(javax.servlet.http.HttpServletResponse response,
java.lang.String reasonWhyForbidden)
Sends 403 Forbidden response with text message regarding the reason, in text/plain format (for better reading from console)
|
static void |
sendTextPlain(javax.servlet.http.HttpServletResponse response,
int statusCode,
java.lang.String text)
Sends plain text response with given statusCode and text message, in text/plain format and with UTF-8 character encoding
|
static void |
setContentDisposition(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String fileName)
Sets the proper "Content-Disposition" response header.
|
static void |
setContentDisposition(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String fileName,
boolean considerMimeType)
Sets the proper "Content-Disposition" response header.
|
static void |
setContextProject(java.util.Map model,
SBuildType buildType)
Set parameter
ContextProjectInfo.CONTEXT_PROJECT_ATTR into model from a given buildType, if possible |
static void |
setMimeType(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String relativePath)
Computes MIME type for the file located by the specified relative path and sets it into the response.
|
static java.lang.String |
truncateStringValueWithDotsInTheMiddle(java.lang.String str,
int maxLength)
Truncates string by cutting the middle part if string length exceeds specified max length.
|
static boolean |
withExperimentalOverview(javax.servlet.http.HttpServletRequest request) |
static boolean |
withExperimentalUI(javax.servlet.http.HttpServletRequest request)
Deprecated.
experimental features are only used on dedicated pages, see withExperimentalOverview
|
public static final java.lang.String HTTP_AUTH_PREFIX
public static final java.lang.String GUEST_AUTH_PREFIX
public static final java.lang.String DEFAULT_WEB_DATE_FORMAT
public static final java.lang.String TC_SKIP_LOG_SESSION_MARKER
public static final java.lang.String FRAGMENT_ID_PARAM
@NotNull public static java.lang.String getPathWithoutContext(@NotNull javax.servlet.http.HttpServletRequest request)
request
- requestgetOriginalPathWithoutContext(javax.servlet.http.HttpServletRequest)
@NotNull public static java.lang.String getOriginalPathWithoutContext(@NotNull javax.servlet.http.HttpServletRequest request)
request
- requestgetPathWithoutContext(javax.servlet.http.HttpServletRequest)
@NotNull public static java.lang.String getPathWithoutContext(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull java.lang.String reqURI)
request
- requestreqURI
- request uri to process@NotNull public static java.lang.String getPathFromUrl(@NotNull java.lang.String url)
url
- urlpublic static java.lang.String getPathWithoutAuthenticationType(@NotNull javax.servlet.http.HttpServletRequest request)
request
- requestgetOriginalPathWithoutContext(javax.servlet.http.HttpServletRequest)
,
getPathWithoutAuthenticationType(String)
public static java.lang.String getOriginalPathWithoutAuthenticationType(@NotNull javax.servlet.http.HttpServletRequest request)
request
- requestgetOriginalPathWithoutContext(javax.servlet.http.HttpServletRequest)
,
getPathWithoutAuthenticationType(javax.servlet.http.HttpServletRequest)
,
getPathWithoutAuthenticationType(String)
public static java.lang.String getPathWithoutAuthenticationType(@NotNull java.lang.String path)
path
- path@NotNull public static java.lang.String removeSessionId(@NotNull java.lang.String uri)
public static java.lang.String combineContextPath(@NotNull java.lang.String prefixPath, @NotNull java.lang.String path)
prefixPath
- prefix pathpath
- path@NotNull public static java.lang.String getRootUrl(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request@NotNull public static java.lang.StringBuilder getOriginUrl(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean isAbsolute(@NotNull java.lang.String url)
url
- urlpublic static boolean isStandardPort(int port, boolean isHttps)
public static int getDefaultPort(@NotNull java.lang.String scheme)
scheme
- request schema@Deprecated @NotNull public static java.lang.String getMimeType(javax.servlet.http.HttpServletRequest request, java.lang.String relativePath)
getMimeType(HttpServletRequest, String, boolean)
instead@NotNull public static java.lang.String getMimeType(javax.servlet.http.HttpServletRequest request, java.lang.String relativePath, boolean safeMode)
relativePath
- path to a file which MIME type is to be setsafeMode
- 'false' to use all known mime types (should only be used for serving files coming from trusted sources),
'true' to select from "text/plain" : "application/octet-stream" which ensures for example that content of html files is not be rendered by the browserpublic static void setMimeType(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String relativePath)
request
- requestresponse
- responserelativePath
- path to a file which MIME type is to be setpublic static void notFound(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String errorString, @Nullable com.intellij.openapi.diagnostic.Logger log) throws java.io.IOException
response
- responseerrorString
- message to loglog
- logger to log message tojava.io.IOException
- IO exception if failed to write 404 responsepublic static void sendForbiddenPlain(@NotNull javax.servlet.http.HttpServletResponse response, @NotNull java.lang.String reasonWhyForbidden) throws java.io.IOException
java.io.IOException
public static void sendErrorPlain(@NotNull javax.servlet.http.HttpServletResponse response, int statusCode, java.lang.String text) throws java.io.IOException
text
- follows status code in the output bodyjava.io.IOException
public static void sendTextPlain(@NotNull javax.servlet.http.HttpServletResponse response, int statusCode, java.lang.String text) throws java.io.IOException
text
- follows status code in the output bodyjava.io.IOException
@Deprecated @NotNull public static java.lang.String encode(@Nullable java.lang.String string)
string
- string to encode@Deprecated @NotNull public static java.lang.String decode(@Nullable java.lang.String string)
string
- string to decodepublic static java.lang.String escapeXml(java.lang.String text)
text
- test@NotNull public static java.lang.String createPathWithParameters(@NotNull javax.servlet.http.HttpServletRequest request)
createPathWithParameters(javax.servlet.http.HttpServletRequest, jetbrains.buildServer.web.util.WebUtil.ParameterFilter)
with default filter which accepts all parameters.request
- current http request.@NotNull public static java.lang.String createPathWithParameters(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull WebUtil.ParameterFilter filter)
this method will return: /context/path/to/some/file.html?param1=value
request
- requestfilter
- to strip unneeded parameters from query string@NotNull public static java.lang.String createRequestParameters(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request@NotNull public static java.lang.String createRequestParameters(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull WebUtil.ParameterFilter filter)
request
- requestfilter
- to strip unneeded parameter from query@NotNull public static java.lang.String createRequestWithoutInit(@NotNull javax.servlet.http.HttpServletRequest request)
request
- the requestpublic static java.lang.String getFilename(@NotNull SBuild build)
build
- build for which filename should be returnedpublic static boolean requirePostMethodFail(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response)
@NotNull public static java.lang.String escapeForJavaScriptIdentifier(@Nullable java.lang.String text)
text
- id to escapepublic static java.lang.String escapeForJavaScript(@NotNull java.lang.String text, boolean removeLineFeeds, boolean forHTMLAttribute)
text
- text to escaperemoveLineFeeds
- whether to remove line feeds from the textforHTMLAttribute
- specify true if text is supposed to be used in HTML attribute, in this case some characters will be replaced with HTML entities.@NotNull public static java.lang.String escapeUrlForQuotes(@Nullable java.lang.String url)
Suppose you use the ${url}
like this in your JSP:
SomeJsFunction("foo", '${url}', 0);Passing the
url
equal to http://server/page.html?','');alert(1)//
will lead to
SomeJsFunction("foo", 'http://server/page.html?','');alert(1)//', 0);Which executes not only
SomeJsFunction
function, but also user provided code (alert(1)
).
A similar issue can arise in pure HTML like this:
<form action="${url}">...</form>If the
url
is http://server/page.html?"><script>alert(1)</script>
In order to resolve the issue, but still support URLs containing special characters, this function urlencodes
dangerous characters with %
-entities.
url
- the url to process.public static void dumpRequest(javax.servlet.http.HttpServletRequest request, java.io.PrintStream out)
request
- requestout
- print streampublic static java.lang.String getRequestDump(@NotNull javax.servlet.http.HttpServletRequest request)
request
- requestpublic static java.lang.String hostAndPort(@NotNull java.lang.String ipOrHost, @Nullable java.lang.Integer portNumber)
public static java.lang.String getShortRequestDescription(javax.servlet.http.HttpServletRequest request)
@NotNull public static java.lang.String getLoggableSessionId(@Nullable java.lang.String httpSessionId)
public static java.lang.String getRemoteAddress(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean isSecure(@NotNull javax.servlet.http.HttpServletRequest request)
public static java.lang.String getScheme(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request.public static java.lang.String getServerName(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request.public static int getServerPort(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request.@NotNull public static java.lang.String getHeaderDump(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull java.lang.String headerName)
public static int getMaxUiTestLimit()
public static void logRequestWarn(@NotNull java.lang.String message, @Nullable java.lang.Exception e, @NotNull javax.servlet.http.HttpServletRequest request, @NotNull com.intellij.openapi.diagnostic.Logger log)
message
- warning messagee
- exception that occurred, if anyrequest
- request during which the error occurredlog
- the log to add message topublic static java.lang.String makeBreakable(@NotNull java.lang.String source, @NotNull java.lang.String regexp, boolean escape)
source
- source textregexp
- a regular expression identifying a place where replacement should be doneescape
- whether entities should be escapedpublic static java.lang.String firstLine(java.lang.String text)
text
- source textpublic static javax.servlet.http.Cookie createSessionCookie(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String value)
request
- HTTP requestname
- cookie namevalue
- cookie valuepublic static javax.servlet.http.Cookie createCookie(javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String value, int age)
request
- HTTP requestname
- cookie namevalue
- cookie valueage
- age in secondspublic static boolean isProbablyBrowser(javax.servlet.http.HttpServletRequest request)
request
- HTTP request@Nullable public static java.lang.String getUserAgent(@NotNull javax.servlet.http.HttpServletRequest request)
@Nullable public static java.lang.String truncateStringValueWithDotsInTheMiddle(java.lang.String str, int maxLength)
str
- string to trimmaxLength
- max lengthpublic static boolean isJspPath(java.lang.String path)
path
- pathpublic static boolean isIE10OrLower(@NotNull javax.servlet.http.HttpServletRequest request)
request
- http requestpublic static boolean isIE(@NotNull javax.servlet.http.HttpServletRequest request)
request
- http requestpublic static boolean isSafari(@NotNull javax.servlet.http.HttpServletRequest request)
request
- http requestpublic static void addCacheHeadersForIE(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response)
request
- an http requestresponse
- the response to makepublic static void setContentDisposition(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull java.lang.String fileName)
fileName
specified.request
- http requestresponse
- http responsefileName
- file namepublic static void setContentDisposition(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull java.lang.String fileName, boolean considerMimeType)
fileName
specified (if considerMimeType
is true
).
Since 7.1, the request parameters "forceInline"
and "forceAttachment"
can be used to apply "inline" or "attachment" type no matter what.
Since 8.0 supports correct Unicode file names for all modern browsers.
request
- http requestresponse
- http responsefileName
- file nameconsiderMimeType
- use "inline" type or not depending on fileName
extension
(note: "inline" may cause problems in IE)@NotNull public static java.lang.String getContentDispositionValue(@NotNull javax.servlet.http.HttpServletRequest request, @Nullable java.lang.String type, @NotNull java.lang.String fileName)
Content-Disposition
value based on the type
("inline", "attachment")
and current request
.request
- http requesttype
- disposition type ("inline", "attachment". Can be null
, in this case it is not included)fileName
- file namepublic static boolean isAjaxRequest(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request to checkpublic static boolean isWebSocketUpgradeRequest(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean isPageFragmentRequest(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request to check@NotNull public static java.lang.String getOriginalRequestUrl(@NotNull javax.servlet.http.HttpServletRequest request)
request
- the requestgetRequestUrl(HttpServletRequest)
@NotNull public static java.lang.String getRequestUrl(@NotNull javax.servlet.http.HttpServletRequest request)
request
request
- the request@NotNull public static java.lang.String getRequestUrl(@NotNull java.lang.String requestURI, @NotNull javax.servlet.http.HttpServletRequest request)
request
request
- the request@NotNull public static java.lang.String getDeepestRequestUrl(@NotNull javax.servlet.http.HttpServletRequest request)
request
- request@NotNull public static javax.servlet.ServletContext getServletContext(@NotNull javax.servlet.http.HttpServletRequest request)
public static void preventCaching(@NotNull javax.servlet.http.HttpServletResponse response)
http://www.mnot.net/cache_docs
.@Nullable public static java.lang.String findRefererInRequest(@NotNull javax.servlet.http.HttpServletRequest request)
"REFERER"
or "HTTP_REFERER"
header).
All modern browsers include the previous used page URL for one of those.request
- the requestpublic static void setContextProject(@NotNull java.util.Map model, @Nullable SBuildType buildType)
ContextProjectInfo.CONTEXT_PROJECT_ATTR
into model from a given buildType, if possiblemodel
- Spring web modelpublic static boolean isInclude(@NotNull javax.servlet.http.HttpServletRequest request)
request
- current request objectRequestDispatcher.include(ServletRequest, ServletResponse)
public static boolean isForward(@NotNull javax.servlet.http.HttpServletRequest request)
request
- current request objectRequestDispatcher.forward(ServletRequest, ServletResponse)
public static boolean isJspPrecompilationRequest(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean isWebComponentSupportAware(@NotNull javax.servlet.http.HttpServletRequest request)
@Deprecated public static boolean isReactUISupportAware(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean experimentalUIAvailable()
public static boolean isExperimentalUIOptional()
@Deprecated public static boolean experimentalUIToggleEnabled(@NotNull javax.servlet.http.HttpServletRequest request)
@Deprecated public static boolean withExperimentalUI(@NotNull javax.servlet.http.HttpServletRequest request)
public static boolean withExperimentalOverview(@NotNull javax.servlet.http.HttpServletRequest request)
public static java.lang.String replace(java.lang.String text, java.util.regex.Pattern pattern, java.util.function.Function<java.lang.String,java.lang.String> nonMatched, java.util.function.Function<java.util.regex.Matcher,java.lang.String> matched)
"P"
Input | Call Chain |
---|---|
"" | nonMatched("") |
"A" | nonMatched("A") |
"AP" | nonMatched("A"), matched("P"), nonMatched("") |
"APA" | nonMatched("A"), matched("P"), nonMatched("A") |
"P" | nonMatched(""), matched("P"), nonMatched("") |
WebUtil.replace("a b c", Pattern.compile("b"), WebUtil::escapeXml, m -> "<b>" + WebUtil.escapeXml(m.group())) + "</b>";
nonMatched
- called for non-matched fragmentsmatched
- called for matched fragmentspublic static java.lang.String replace(java.lang.String text, java.util.regex.Matcher matcher, java.util.function.Function<java.lang.String,java.lang.String> nonMatched, java.util.function.Function<java.util.regex.Matcher,java.lang.String> matched)
replace(String, Pattern, Function, Function)
public static boolean isCommonExternalError(@Nullable java.lang.Throwable e)