Skip to content
Snippets Groups Projects
Commit 46a90c56 authored by Johan Schön's avatar Johan Schön
Browse files

Added downloaded_bytes() and total_bytes().

Rev: lib/modules/Protocols.pmod/HTTP.pmod/Query.pike:1.12
parent 72d720c6
No related branches found
No related tags found
No related merge requests found
......@@ -84,6 +84,13 @@
**! method string data()
**! Gives back the data as a string.
**!
**! metohd int downloaded_bytes()
**! Gives back the number of downloaded bytes.
**!
**! method int total_bytes()
**! Gives back the size of a file if a content-length header is present
**! and parsed at the time of evaluation. Otherwise returns -1.
**!
**! object(pseudofile) file()
**! object(pseudofile) file(mapping newheaders,void|mapping removeheaders)
**! object(pseudofile) datafile();
......@@ -535,6 +542,23 @@ string data()
return buf[datapos..];
}
int downloaded_bytes()
{
if(datapos)
return sizeof(buf)-datapos;
else
return 0;
}
int total_bytes()
{
int len=(int)headers["content-length"];
if(zero_type(len))
return -1;
else
return len;
}
array|mapping|string cast(string to)
{
switch (to)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment