summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ceafe8a)
The variable "Size" was misleading and caused bug #
1445239. To
avoid similar issues in the future, rename it to make the meaning
more obvious.
git-dch: ignore
{
if (me->Server->Result != 416 && me->Server->StartPos != 0)
;
{
if (me->Server->Result != 416 && me->Server->StartPos != 0)
;
- else if (me->Server->Result == 416 && me->Server->Size == me->File->FileSize())
+ else if (me->Server->Result == 416 && me->Server->TotalFileSize == me->File->FileSize())
{
me->Server->Result = 200;
{
me->Server->Result = 200;
- me->Server->StartPos = me->Server->Size;
+ me->Server->StartPos = me->Server->TotalFileSize;
// the actual size is not important for https as curl will deal with it
// by itself and e.g. doesn't bother us with transport-encoding…
me->Server->JunkSize = std::numeric_limits<unsigned long long>::max();
// the actual size is not important for https as curl will deal with it
// by itself and e.g. doesn't bother us with transport-encoding…
me->Server->JunkSize = std::numeric_limits<unsigned long long>::max();
Major = 0;
Minor = 0;
Result = 0;
Major = 0;
Minor = 0;
Result = 0;
JunkSize = 0;
StartPos = 0;
Encoding = Closes;
JunkSize = 0;
StartPos = 0;
Encoding = Closes;
// On partial content (206) the Content-Length less than the real
// size, so do not set it here but leave that to the Content-Range
// header instead
// On partial content (206) the Content-Length less than the real
// size, so do not set it here but leave that to the Content-Range
// header instead
- if(Result != 206 && Size == 0)
- Size = DownloadSize;
+ if(Result != 206 && TotalFileSize == 0)
+ TotalFileSize = DownloadSize;
HaveContent = true;
// §14.16 says 'byte-range-resp-spec' should be a '*' in case of 416
HaveContent = true;
// §14.16 says 'byte-range-resp-spec' should be a '*' in case of 416
- if (Result == 416 && sscanf(Val.c_str(), "bytes */%llu",&Size) == 1)
+ if (Result == 416 && sscanf(Val.c_str(), "bytes */%llu",&TotalFileSize) == 1)
; // we got the expected filesize which is all we wanted
; // we got the expected filesize which is all we wanted
- else if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2)
+ else if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&TotalFileSize) != 2)
return _error->Error(_("The HTTP server sent an invalid Content-Range header"));
return _error->Error(_("The HTTP server sent an invalid Content-Range header"));
- if ((unsigned long long)StartPos > Size)
+ if ((unsigned long long)StartPos > TotalFileSize)
return _error->Error(_("This HTTP server has broken range support"));
// figure out what we will download
return _error->Error(_("This HTTP server has broken range support"));
// figure out what we will download
- DownloadSize = Size - StartPos;
+ DownloadSize = TotalFileSize - StartPos;
struct stat SBuf;
if (stat(Queue->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
{
struct stat SBuf;
if (stat(Queue->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
{
- if ((unsigned long long)SBuf.st_size == Server->Size)
+ if ((unsigned long long)SBuf.st_size == Server->TotalFileSize)
{
// the file is completely downloaded, but was not moved
if (Server->HaveContent == true)
{
// the file is completely downloaded, but was not moved
if (Server->HaveContent == true)
Server->RunData(&DevNull);
}
Server->HaveContent = false;
Server->RunData(&DevNull);
}
Server->HaveContent = false;
- Server->StartPos = Server->Size;
+ Server->StartPos = Server->TotalFileSize;
Server->Result = 200;
}
else if (unlink(Queue->DestFile.c_str()) == 0)
Server->Result = 200;
}
else if (unlink(Queue->DestFile.c_str()) == 0)
// This is some sort of 2xx 'data follows' reply
Res.LastModified = Server->Date;
// This is some sort of 2xx 'data follows' reply
Res.LastModified = Server->Date;
- Res.Size = Server->Size;
+ Res.Size = Server->TotalFileSize;
// Open the file
delete File;
// Open the file
delete File;
char Code[360];
// These are some statistics from the last parsed header lines
char Code[360];
// These are some statistics from the last parsed header lines
- unsigned long long Size; // total size of the usable content (aka: the file)
- unsigned long long DownloadSize; // size we actually download (can be smaller than Size if we have partial content)
- unsigned long long JunkSize; // size of junk content (aka: server error pages)
+
+ // total size of the usable content (aka: the file)
+ unsigned long long TotalFileSize;
+ // size we actually download (can be smaller than Size if we have partial content)
+ unsigned long long DownloadSize;
+ // size of junk content (aka: server error pages)
+ unsigned long long JunkSize;
+ // The start of the data (for partial content)
unsigned long long StartPos;
unsigned long long StartPos;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
RunHeadersResult RunHeaders(FileFd * const File, const std::string &Uri);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
RunHeadersResult RunHeaders(FileFd * const File, const std::string &Uri);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
- virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; Size = 0; JunkSize = 0;
+ virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; TotalFileSize = 0; JunkSize = 0;
StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false;
State = Header; Persistent = false; Pipeline = true;};
virtual bool WriteResponse(std::string const &Data) = 0;
StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false;
State = Header; Persistent = false; Pipeline = true;};
virtual bool WriteResponse(std::string const &Data) = 0;