Package jetbrains.buildServer.web.util
Class WebUtilInternal
- java.lang.Object
-
- jetbrains.buildServer.web.util.WebUtilInternal
-
public class WebUtilInternal extends Object
- Author:
- Yegor.Yarko Date: 22/03/2019
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
WebUtilInternal.WriterConsumer<E extends Exception>
-
Constructor Summary
Constructors Constructor Description WebUtilInternal()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getLocalRootUrl(javax.servlet.http.HttpServletRequest request)
Best guess of the root server URL which can be used on the machine where the server runs to contact the server web endpoint (the same one as used by the original request)static Writer
getWriter(javax.servlet.http.HttpServletResponse response)
static <E extends Exception>
voidwithWriter(javax.servlet.http.HttpServletResponse response, WebUtilInternal.WriterConsumer<E> supplier)
Writes with theWriter
provided bygetWriter(HttpServletResponse)
and closes it.
-
-
-
Method Detail
-
getLocalRootUrl
@NotNull public static String getLocalRootUrl(@NotNull javax.servlet.http.HttpServletRequest request)
Best guess of the root server URL which can be used on the machine where the server runs to contact the server web endpoint (the same one as used by the original request)
-
withWriter
public static <E extends Exception> void withWriter(@NotNull javax.servlet.http.HttpServletResponse response, @NotNull WebUtilInternal.WriterConsumer<E> supplier) throws IOException, E extends Exception
Writes with theWriter
provided bygetWriter(HttpServletResponse)
and closes it.- Throws:
IOException
E extends Exception
- Since:
- 2022.1
-
getWriter
@NotNull public static Writer getWriter(@NotNull javax.servlet.http.HttpServletResponse response) throws IOException
Returns the
Writer
of theresponse
with theUTF-8
encoding.This method is trying to use the
ServletResponse.getOutputStream()
if possible that is preferred comparing with theServletResponse.getWriter()
, because thePrintWriter
returned by it silently eats allIOException
.- Throws:
IOException
- Since:
- 2022.1
-
-