send_extra_headers

This commit is contained in:
David Rose 2002-11-05 19:42:12 +00:00
parent 5b38176c95
commit 1e96f1ca63
3 changed files with 43 additions and 1 deletions

View File

@ -383,6 +383,37 @@ reset() {
reset_to_new();
}
////////////////////////////////////////////////////////////////////
// Function: HTTPChannel::clear_extra_headers
// Access: Published
// Description: Resets the extra headers that were previously added
// via calls to send_extra_header().
////////////////////////////////////////////////////////////////////
INLINE void HTTPChannel::
clear_extra_headers() {
_send_extra_headers = string();
}
////////////////////////////////////////////////////////////////////
// Function: HTTPChannel::send_extra_header
// Access: Published
// Description: Specifies an additional key: value pair that is added
// into the header sent to the server with the next
// request. This is passed along with no interpretation
// by the HTTPChannel code. You may call this
// repeatedly to append multiple headers.
//
// This is persistent for one request only; it must be
// set again for each new request.
////////////////////////////////////////////////////////////////////
INLINE void HTTPChannel::
send_extra_header(const string &key, const string &value) {
_send_extra_headers += key;
_send_extra_headers += ": ";
_send_extra_headers += value;
_send_extra_headers += "\r\n";
}
////////////////////////////////////////////////////////////////////
// Function: HTTPChannel::get_document
// Access: Published

View File

@ -202,6 +202,7 @@ write_headers(ostream &out) const {
bool HTTPChannel::
run() {
if (_state == _done_state || _state == S_failure) {
clear_extra_headers();
if (!reached_done_state()) {
return false;
}
@ -341,6 +342,7 @@ run() {
}
if (_state == _done_state || _state == S_failure) {
clear_extra_headers();
// We've reached our terminal state.
return reached_done_state();
}
@ -1022,6 +1024,10 @@ run_request_sent() {
return false;
}
// Ok, we've established an HTTP connection to the server. Our
// extra send headers have done their job; clear them for next time.
clear_extra_headers();
_state = S_reading_header;
_current_field_name = string();
_current_field_value = string();
@ -2307,7 +2313,8 @@ make_request_text() {
_www_auth->generate(_method, _url.get_path(), _www_username, _body);
_request_text += "\r\n";
}
_request_text += _send_extra_headers;
_request_text += "\r\n";
_request_text += _body;
}

View File

@ -109,6 +109,9 @@ PUBLISHED:
INLINE void reset();
INLINE void clear_extra_headers();
INLINE void send_extra_header(const string &key, const string &value);
INLINE bool get_document(const URLSpec &url);
INLINE bool get_subdocument(const URLSpec &url,
size_t first_byte, size_t last_byte);
@ -208,6 +211,7 @@ private:
double _seconds_per_update;
int _bytes_per_update;
bool _nonblocking;
string _send_extra_headers;
URLSpec _url;
HTTPEnum::Method _method;