java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java | 25 ++++++----
proxy/proxy/apacheHandler.py | 3 -
2 files changed, 17 insertions(+), 11 deletions(-)
New commits:
commit 02e1328e9a50a9360c1904e8d5a78c0c46c5befc
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Jun 29 15:49:12 2010 +0200
if file is rpm package, use checksum from db, otherwise read whole file
diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
index f747bd9..a07ce16 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java
@@ -410,7 +410,7 @@ public class DownloadFile extends DownloadAction {
KickstartSession ksession = (KickstartSession) params.get(SESSION);
KickstartSessionState newState = null;
KickstartableTree tree = (KickstartableTree) params.get(TREE);
- Package rpmPackage;
+ Package rpmPackage = null;
Channel child = (Channel) params.get(CHILD);
if (tree.getBasePath().indexOf(kickstartMount) == 0) {
@@ -505,7 +505,7 @@ public class DownloadFile extends DownloadAction {
}
if (request.getMethod().equals("HEAD")) {
log.debug("Method is HEAD .. serving checksum");
- return manualServeChecksum(response, diskPath);
+ return manualServeChecksum(response, rpmPackage, diskPath);
}
else if (request.getHeader("Range") != null) {
log.debug("range detected. serving chunk of file");
@@ -565,19 +565,24 @@ public class DownloadFile extends DownloadAction {
// Ported from perl - needed for proxy support
private StreamInfo manualServeChecksum(HttpServletResponse response,
- String diskPath) throws IOException {
+ Package rpmPackage, String diskPath) throws IOException {
response.setContentType("application/octet-stream");
-
+ String checksum;
// Obtain the checksum for the file in question and stick it in the
// outgoing HTTP headers under "X-RHN-Checksum".
- File f = new File(diskPath);
- if (!f.exists()) {
- log.error("manualServeChecksum :: File not found: " + diskPath);
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- return getStreamForText("".getBytes());
+ if (rpmPackage != null && rpmPackage.getChecksum() != null &&
+ rpmPackage.getChecksum().getChecksum() != null) {
+ checksum = rpmPackage.getChecksum().getChecksum();
+ } else {
+ File f = new File(diskPath);
+ if (!f.exists()) {
+ log.error("manualServeChecksum :: File not found: " +
diskPath);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return getStreamForText("".getBytes());
+ }
+ checksum = MD5Sum.getFileMD5Sum(f);
}
- String checksum = MD5Sum.getFileMD5Sum(f);
// Create some headers.
response.setContentLength(0);
response.addHeader("X-RHN-Checksum", checksum);
commit e783a6e7a1c329c0f2d9b64dadeaf6e26f5191cc
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Jun 29 13:19:24 2010 +0200
609040 - if we request checksum of file, do not sent Range http header
diff --git a/proxy/proxy/apacheHandler.py b/proxy/proxy/apacheHandler.py
index f233bd0..23216ed 100644
--- a/proxy/proxy/apacheHandler.py
+++ b/proxy/proxy/apacheHandler.py
@@ -238,7 +238,8 @@ class apacheHandler(rhnApache):
hdrs = UserDictCase()
for k in req.headers_in.keys():
- hdrs[k] = req.headers_in[k]
+ if k.lower() != 'range': # we want checksum of whole file
+ hdrs[k] = req.headers_in[k]
log_debug(9, "Using existing headers_in", hdrs)
connection.request("HEAD", pingURL, None, hdrs)
Show replies by date