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; }