Skip to content

Commit d2ec085

Browse files
committed
Allow for either getOutpuStream or getWriter to be used before sendRedirect is called.
1 parent 3ac71dc commit d2ec085

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/src/main/java/org/kohsuke/stapler/ResponseImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ private <T extends PrintWriter> T recordOutput(T obj) {
118118
return obj;
119119
}
120120

121+
private void closeOutput() throws IOException {
122+
if (mode == OutputMode.BYTE) {
123+
getOutputStream().close();
124+
} else if (mode == OutputMode.CHAR) {
125+
getWriter().close();
126+
}
127+
128+
}
129+
121130
public void forward(Object it, String url, StaplerRequest request) throws ServletException, IOException {
122131
stapler.invoke(request, response, it, url);
123132
}
@@ -190,7 +199,7 @@ public void sendRedirect(int statusCode, @Nonnull String url) throws IOException
190199

191200
setStatus(statusCode);
192201
setHeader("Location",url);
193-
getOutputStream().close();
202+
closeOutput();
194203
}
195204

196205

0 commit comments

Comments
 (0)