From 207f4c582ea04812d5bcc712b71da28e44e07c59 Mon Sep 17 00:00:00 2001 From: mindless Date: Mon, 8 Feb 2010 18:35:32 +0000 Subject: [PATCH] [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 --- core/src/main/java/hudson/model/DownloadService.java | 4 +++- core/src/main/java/hudson/model/UpdateSite.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/DownloadService.java b/core/src/main/java/hudson/model/DownloadService.java index 0ea2f25cd7..0e918e1424 100644 --- a/core/src/main/java/hudson/model/DownloadService.java +++ b/core/src/main/java/hudson/model/DownloadService.java @@ -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 } /** diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index fd4c08e00b..863a5f2bb6 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -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 } /**