提交 207f4c58 编写于 作者: M mindless

[HUDSON-5536] set text/plain content type in doPostBack response so browser won't

try to parse response (resulting in "no element found" in firefox error console).
Not the fix for 5536 itself, but nice to avoid js error after successful update.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@27145 71c3de6d-444a-0410-be80-ed276b4c234a
上级 3af3cc8e
......@@ -39,6 +39,7 @@ import java.util.logging.Logger;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
/**
* Service for plugins to periodically retrieve update data files
......@@ -200,13 +201,14 @@ public class DownloadService extends PageDecorator {
/**
* This is where the browser sends us the data.
*/
public void doPostBack(StaplerRequest req) throws IOException {
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
long dataTimestamp = System.currentTimeMillis();
TextFile df = getDataFile();
df.write(IOUtils.toString(req.getInputStream(),"UTF-8"));
df.file.setLastModified(dataTimestamp);
due = dataTimestamp+getInterval();
LOGGER.info("Obtained the updated data file for "+id);
rsp.setContentType("text/plain"); // So browser won't try to parse response
}
/**
......
......@@ -134,7 +134,7 @@ public class UpdateSite {
/**
* This is the endpoint that receives the update center data file from the browser.
*/
public void doPostBack(StaplerRequest req) throws IOException, GeneralSecurityException {
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException {
dataTimestamp = System.currentTimeMillis();
String json = IOUtils.toString(req.getInputStream(),"UTF-8");
JSONObject o = JSONObject.fromObject(json);
......@@ -150,6 +150,7 @@ public class UpdateSite {
LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id);
getDataFile().write(json);
rsp.setContentType("text/plain"); // So browser won't try to parse response
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册