17 INLINE HTTPClient *HTTPChannel::
26 INLINE
bool HTTPChannel::
28 return (_state != S_failure && (get_status_code() / 100) == 2 &&
29 (_server_response_has_no_body || !_source.is_null()));
36 INLINE
bool HTTPChannel::
37 is_connection_ready()
const {
38 return (!_source.is_null() && _state == S_ready);
47 INLINE
const URLSpec &HTTPChannel::
49 return _document_spec.
get_url();
62 get_document_spec()
const {
63 return _document_spec;
70 INLINE HTTPEnum::HTTPVersion HTTPChannel::
71 get_http_version()
const {
79 INLINE
const std::string &HTTPChannel::
80 get_http_version_string()
const {
81 return _http_version_string;
94 INLINE
int HTTPChannel::
95 get_status_code()
const {
96 return _status_entry._status_code;
106 INLINE
const std::string &HTTPChannel::
107 get_www_realm()
const {
117 INLINE
const std::string &HTTPChannel::
118 get_proxy_realm()
const {
129 INLINE
const URLSpec &HTTPChannel::
130 get_redirect()
const {
139 INLINE
int HTTPChannel::
140 get_num_redirect_steps()
const {
141 return _redirect_trail.size();
149 INLINE
const URLSpec &HTTPChannel::
150 get_redirect_step(
int n)
const {
151 nassertr(n >= 0 && n < (
int)_redirect_trail.size(), _redirect_trail[0]);
152 return _redirect_trail[n];
165 INLINE
void HTTPChannel::
166 set_persistent_connection(
bool persistent_connection) {
167 _persistent_connection = persistent_connection;
176 INLINE
bool HTTPChannel::
177 get_persistent_connection()
const {
178 return _persistent_connection;
188 INLINE
void HTTPChannel::
189 set_allow_proxy(
bool allow_proxy) {
190 _allow_proxy = allow_proxy;
200 INLINE
bool HTTPChannel::
201 get_allow_proxy()
const {
220 INLINE
void HTTPChannel::
221 set_proxy_tunnel(
bool proxy_tunnel) {
222 _proxy_tunnel = proxy_tunnel;
230 INLINE
bool HTTPChannel::
231 get_proxy_tunnel()
const {
232 return _proxy_tunnel;
243 INLINE
void HTTPChannel::
244 set_connect_timeout(
double connect_timeout) {
245 _connect_timeout = connect_timeout;
252 INLINE
double HTTPChannel::
253 get_connect_timeout()
const {
254 return _connect_timeout;
269 INLINE
void HTTPChannel::
270 set_blocking_connect(
bool blocking_connect) {
271 _blocking_connect = blocking_connect;
280 INLINE
bool HTTPChannel::
281 get_blocking_connect()
const {
282 return _blocking_connect;
296 INLINE
void HTTPChannel::
297 set_http_timeout(
double http_timeout) {
298 _http_timeout = http_timeout;
305 INLINE
double HTTPChannel::
306 get_http_timeout()
const {
307 return _http_timeout;
322 INLINE
void HTTPChannel::
323 set_skip_body_size(
size_t skip_body_size) {
324 _skip_body_size = skip_body_size;
332 INLINE
size_t HTTPChannel::
333 get_skip_body_size()
const {
334 return _skip_body_size;
344 INLINE
void HTTPChannel::
345 set_idle_timeout(
double idle_timeout) {
346 _idle_timeout = idle_timeout;
353 INLINE
double HTTPChannel::
354 get_idle_timeout()
const {
355 return _idle_timeout;
373 INLINE
void HTTPChannel::
374 set_download_throttle(
bool download_throttle) {
375 _download_throttle = download_throttle;
382 INLINE
bool HTTPChannel::
383 get_download_throttle()
const {
384 return _download_throttle;
392 INLINE
void HTTPChannel::
393 set_max_bytes_per_second(
double max_bytes_per_second) {
394 _max_bytes_per_second = max_bytes_per_second;
395 _bytes_per_update = int(_max_bytes_per_second * _seconds_per_update);
402 INLINE
double HTTPChannel::
403 get_max_bytes_per_second()
const {
404 return _max_bytes_per_second;
412 INLINE
void HTTPChannel::
413 set_max_updates_per_second(
double max_updates_per_second) {
414 nassertv(max_updates_per_second != 0.0f);
415 _max_updates_per_second = max_updates_per_second;
416 _seconds_per_update = 1.0f / _max_updates_per_second;
417 _bytes_per_update = int(_max_bytes_per_second * _seconds_per_update);
424 INLINE
double HTTPChannel::
425 get_max_updates_per_second()
const {
426 return _max_updates_per_second;
433 INLINE
void HTTPChannel::
434 set_content_type(std::string content_type) {
435 _content_type = content_type;
441 INLINE std::string HTTPChannel::
442 get_content_type()
const {
443 return _content_type;
453 INLINE
void HTTPChannel::
454 set_expected_file_size(
size_t file_size) {
455 _expected_file_size = file_size;
456 _got_expected_file_size =
true;
467 INLINE
bool HTTPChannel::
468 is_file_size_known()
const {
469 return _got_file_size;
478 INLINE
size_t HTTPChannel::
479 get_first_byte_requested()
const {
480 return _first_byte_requested;
489 INLINE
size_t HTTPChannel::
490 get_last_byte_requested()
const {
491 return _last_byte_requested;
501 INLINE
size_t HTTPChannel::
502 get_first_byte_delivered()
const {
503 return _first_byte_delivered;
513 INLINE
size_t HTTPChannel::
514 get_last_byte_delivered()
const {
515 return _last_byte_delivered;
529 INLINE
void HTTPChannel::
531 reset_for_new_request();
533 _status_list.clear();
546 INLINE
void HTTPChannel::
548 _status_list.push_back(_status_entry);
556 INLINE
void HTTPChannel::
557 clear_extra_headers() {
558 _send_extra_headers = std::string();
570 INLINE
void HTTPChannel::
571 send_extra_header(
const std::string &key,
const std::string &value) {
572 _send_extra_headers += key;
573 _send_extra_headers +=
": ";
574 _send_extra_headers += value;
575 _send_extra_headers +=
"\r\n";
582 INLINE
bool HTTPChannel::
584 begin_request(HTTPEnum::M_get, url, std::string(),
false, 0, 0);
597 INLINE
bool HTTPChannel::
598 get_subdocument(
const DocumentSpec &url,
size_t first_byte,
size_t last_byte) {
599 begin_request(HTTPEnum::M_get, url, std::string(),
false, first_byte, last_byte);
611 INLINE
bool HTTPChannel::
613 begin_request(HTTPEnum::M_head, url, std::string(),
false, 0, 0);
622 INLINE
bool HTTPChannel::
623 post_form(
const DocumentSpec &url,
const std::string &body) {
624 begin_request(HTTPEnum::M_post, url, body,
false, 0, 0);
634 INLINE
bool HTTPChannel::
635 put_document(
const DocumentSpec &url,
const std::string &body) {
636 begin_request(HTTPEnum::M_put, url, body,
false, 0, 0);
645 INLINE
bool HTTPChannel::
647 begin_request(HTTPEnum::M_delete, url, std::string(),
false, 0, 0);
657 INLINE
bool HTTPChannel::
659 begin_request(HTTPEnum::M_trace, url, std::string(),
false, 0, 0);
672 INLINE
bool HTTPChannel::
674 begin_request(HTTPEnum::M_connect, url, std::string(),
false, 0, 0);
677 return is_connection_ready();
684 INLINE
bool HTTPChannel::
686 begin_request(HTTPEnum::M_options, url, std::string(),
false, 0, 0);
701 INLINE
void HTTPChannel::
703 begin_request(HTTPEnum::M_get, url, std::string(),
true, 0, 0);
713 INLINE
void HTTPChannel::
714 begin_get_subdocument(
const DocumentSpec &url,
size_t first_byte,
716 begin_request(HTTPEnum::M_get, url, std::string(),
true, first_byte, last_byte);
723 INLINE
void HTTPChannel::
725 begin_request(HTTPEnum::M_head, url, std::string(),
true, 0, 0);
737 INLINE
void HTTPChannel::
738 begin_post_form(
const DocumentSpec &url,
const std::string &body) {
739 begin_request(HTTPEnum::M_post, url, body,
true, 0, 0);
754 INLINE
void HTTPChannel::
756 begin_request(HTTPEnum::M_connect, url, std::string(),
true, 0, 0);
766 INLINE
size_t HTTPChannel::
767 get_bytes_downloaded()
const {
768 return _bytes_downloaded;
784 INLINE
size_t HTTPChannel::
785 get_bytes_requested()
const {
786 return _bytes_requested;
801 INLINE
bool HTTPChannel::
802 is_download_complete()
const {
803 return (_download_dest != DD_none &&
804 (_state == S_read_body || _state == S_read_trailer));
810 INLINE HTTPChannel::StatusEntry::
812 _status_code = SC_incomplete;
A container for a URL, e.g.
const std::string & get_url() const
Returns the complete URL specification.
A descriptor that refers to a particular version of a document.