mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
get_bytes_requested
This commit is contained in:
parent
e29e74cf0f
commit
32bb8b1b41
@ -438,6 +438,30 @@ get_bytes_downloaded() const {
|
|||||||
return _bytes_downloaded;
|
return _bytes_downloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: HTTPChannel::get_bytes_requested
|
||||||
|
// Access: Published
|
||||||
|
// Description: When download throttling is in effect
|
||||||
|
// (set_download_throttle() has been set to true) and
|
||||||
|
// non-blocking I/O methods (like begin_get_document())
|
||||||
|
// are used, this returns the number of bytes
|
||||||
|
// "requested" from the server so far: that is, the
|
||||||
|
// theoretical maximum value for get_bytes_downloaded(),
|
||||||
|
// if the server has been keeping up with our demand.
|
||||||
|
//
|
||||||
|
// If this number is less than get_bytes_downloaded(),
|
||||||
|
// then the server has not been supplying bytes fast
|
||||||
|
// enough to meet our own download throttle rate.
|
||||||
|
//
|
||||||
|
// When download throttling is not in effect, or when
|
||||||
|
// the blocking I/O methods (like get_document(), etc.)
|
||||||
|
// are used, this returns 0.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE size_t HTTPChannel::
|
||||||
|
get_bytes_requested() const {
|
||||||
|
return _bytes_requested;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: HTTPChannel::is_download_complete
|
// Function: HTTPChannel::is_download_complete
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -446,6 +470,14 @@ get_bytes_downloaded() const {
|
|||||||
// fully downloaded. If this still returns false after
|
// fully downloaded. If this still returns false after
|
||||||
// processing has completed, there was an error in
|
// processing has completed, there was an error in
|
||||||
// transmission.
|
// transmission.
|
||||||
|
//
|
||||||
|
// Note that simply testing is_download_complete() does
|
||||||
|
// not prove that the requested document was succesfully
|
||||||
|
// retrieved--you might have just downloaded the "404
|
||||||
|
// not found" stub (for instance) that a server would
|
||||||
|
// provide in response to some error condition. You
|
||||||
|
// should also check is_valid() to prove that the file
|
||||||
|
// you expected has been successfully retrieved.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE bool HTTPChannel::
|
INLINE bool HTTPChannel::
|
||||||
is_download_complete() const {
|
is_download_complete() const {
|
||||||
|
@ -61,6 +61,7 @@ HTTPChannel(HTTPClient *client) :
|
|||||||
_read_index = 0;
|
_read_index = 0;
|
||||||
_file_size = 0;
|
_file_size = 0;
|
||||||
_bytes_downloaded = 0;
|
_bytes_downloaded = 0;
|
||||||
|
_bytes_requested = 0;
|
||||||
_status_code = 0;
|
_status_code = 0;
|
||||||
_status_string = string();
|
_status_string = string();
|
||||||
_proxy = _client->get_proxy();
|
_proxy = _client->get_proxy();
|
||||||
@ -221,6 +222,7 @@ run() {
|
|||||||
// Come back later.
|
// Come back later.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
_bytes_requested += _bytes_per_update;
|
||||||
}
|
}
|
||||||
switch (_download_dest) {
|
switch (_download_dest) {
|
||||||
case DD_none:
|
case DD_none:
|
||||||
@ -1142,7 +1144,7 @@ run_download_to_file() {
|
|||||||
while (!_body_stream->eof() && !_body_stream->fail()) {
|
while (!_body_stream->eof() && !_body_stream->fail()) {
|
||||||
_download_to_file.put(ch);
|
_download_to_file.put(ch);
|
||||||
_bytes_downloaded++;
|
_bytes_downloaded++;
|
||||||
if (do_throttle && (++count > _bytes_per_update)) {
|
if (do_throttle && (++count >= _bytes_per_update)) {
|
||||||
// That's enough for now.
|
// That's enough for now.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1186,7 +1188,7 @@ run_download_to_ram() {
|
|||||||
while (!_body_stream->eof() && !_body_stream->fail()) {
|
while (!_body_stream->eof() && !_body_stream->fail()) {
|
||||||
_download_to_ramfile->_data += (char)ch;
|
_download_to_ramfile->_data += (char)ch;
|
||||||
_bytes_downloaded++;
|
_bytes_downloaded++;
|
||||||
if (do_throttle && (++count > _bytes_per_update)) {
|
if (do_throttle && (++count >= _bytes_per_update)) {
|
||||||
// That's enough for now.
|
// That's enough for now.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1285,6 +1287,7 @@ reset_for_new_request() {
|
|||||||
_last_status_code = 0;
|
_last_status_code = 0;
|
||||||
_file_size = 0;
|
_file_size = 0;
|
||||||
_bytes_downloaded = 0;
|
_bytes_downloaded = 0;
|
||||||
|
_bytes_requested = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -119,6 +119,7 @@ PUBLISHED:
|
|||||||
bool download_to_ram(Ramfile *ramfile);
|
bool download_to_ram(Ramfile *ramfile);
|
||||||
|
|
||||||
INLINE size_t get_bytes_downloaded() const;
|
INLINE size_t get_bytes_downloaded() const;
|
||||||
|
INLINE size_t get_bytes_requested() const;
|
||||||
INLINE bool is_download_complete() const;
|
INLINE bool is_download_complete() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -222,6 +223,7 @@ private:
|
|||||||
|
|
||||||
size_t _file_size;
|
size_t _file_size;
|
||||||
size_t _bytes_downloaded;
|
size_t _bytes_downloaded;
|
||||||
|
size_t _bytes_requested;
|
||||||
|
|
||||||
// These members are used to maintain the current state while
|
// These members are used to maintain the current state while
|
||||||
// communicating with the server. We need to store everything in
|
// communicating with the server. We need to store everything in
|
||||||
|
@ -110,9 +110,11 @@ HTTPClient::
|
|||||||
// Before we can free the context, we must remove the X509_STORE
|
// Before we can free the context, we must remove the X509_STORE
|
||||||
// pointer from it, so it won't be destroyed along with it (this
|
// pointer from it, so it won't be destroyed along with it (this
|
||||||
// object is shared among all contexts).
|
// object is shared among all contexts).
|
||||||
nassertv(_ssl_ctx->cert_store == _x509_store);
|
if (_ssl_ctx != (SSL_CTX *)NULL) {
|
||||||
_ssl_ctx->cert_store = NULL;
|
nassertv(_ssl_ctx->cert_store == _x509_store);
|
||||||
SSL_CTX_free(_ssl_ctx);
|
_ssl_ctx->cert_store = NULL;
|
||||||
|
SSL_CTX_free(_ssl_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
// Free all of the expected server definitions.
|
// Free all of the expected server definitions.
|
||||||
clear_expected_servers();
|
clear_expected_servers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user