From d748e470d87222c21f979963871e9237db02fa60 Mon Sep 17 00:00:00 2001 From: kichik Date: Wed, 27 Jun 2007 11:14:21 +0000 Subject: [PATCH] fixed bug #1744091 - NSISdl shows negative values with buggy apache git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5176 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/NSISdl/httpget.cpp | 14 ++++++++++++++ Contrib/NSISdl/httpget.h | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Contrib/NSISdl/httpget.cpp b/Contrib/NSISdl/httpget.cpp index 9a888500..fb18e881 100644 --- a/Contrib/NSISdl/httpget.cpp +++ b/Contrib/NSISdl/httpget.cpp @@ -481,3 +481,17 @@ int JNL_HTTPGet::peek_bytes(char *buf, int len) if (m_con && m_http_state==3) return m_con->peek_bytes(buf,len); return 0; } + +__int64 JNL_HTTPGet::content_length() +{ + char *p=getheader("content-length:"); + if (!p) return 0; + __int64 cl = myatoi64(p); + if (cl > 0) return cl; + + // workaround for bug #1744091 + // some buggy apache servers return negative values for sizes + // over 2gb - fix it for them + if (cl < 0) + return __int64(unsigned(cl)); +} diff --git a/Contrib/NSISdl/httpget.h b/Contrib/NSISdl/httpget.h index c8b2c76a..c87e1811 100644 --- a/Contrib/NSISdl/httpget.h +++ b/Contrib/NSISdl/httpget.h @@ -43,7 +43,6 @@ #define _HTTPGET_H_ #include "connection.h" -#include "util.h" class JNL_HTTPGet { @@ -71,7 +70,7 @@ class JNL_HTTPGet int get_bytes(char *buf, int len); int peek_bytes(char *buf, int len); - __int64 content_length() { char *p=getheader("content-length:"); if (p) return myatoi64(p); return 0; } + __int64 content_length(); JNL_Connection *get_con() { return m_con; }