From 1ad6b0310f0fbcab57820a9908c4c418778c023a Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 29 Oct 2002 22:32:08 +0000 Subject: [PATCH] add put, delete, trace methods --- panda/src/downloader/httpChannel.I | 103 ++++++++++++++++++++--------- panda/src/downloader/httpChannel.h | 7 +- panda/src/downloader/httpEnum.cxx | 12 ++++ panda/src/downloader/httpEnum.h | 5 +- 4 files changed, 92 insertions(+), 35 deletions(-) diff --git a/panda/src/downloader/httpChannel.I b/panda/src/downloader/httpChannel.I index b0b6d9c499..609903372c 100644 --- a/panda/src/downloader/httpChannel.I +++ b/panda/src/downloader/httpChannel.I @@ -383,19 +383,6 @@ reset() { reset_to_new(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::post_form -// Access: Published -// Description: Posts form data to a particular URL and retrieves the -// response. -//////////////////////////////////////////////////////////////////// -INLINE bool HTTPChannel:: -post_form(const URLSpec &url, const string &body) { - begin_request(HTTPEnum::M_post, url, body, false, 0, 0); - run(); - return is_valid(); -} - //////////////////////////////////////////////////////////////////// // Function: HTTPChannel::get_document // Access: Published @@ -442,6 +429,58 @@ get_header(const URLSpec &url) { return is_valid(); } +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::post_form +// Access: Published +// Description: Posts form data to a particular URL and retrieves the +// response. +//////////////////////////////////////////////////////////////////// +INLINE bool HTTPChannel:: +post_form(const URLSpec &url, const string &body) { + begin_request(HTTPEnum::M_post, url, body, false, 0, 0); + run(); + return is_valid(); +} + +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::put_document +// Access: Published +// Description: Uploads the indicated body to the server to replace +// the indicated URL, if the server allows this. +//////////////////////////////////////////////////////////////////// +INLINE bool HTTPChannel:: +put_document(const URLSpec &url, const string &body) { + begin_request(HTTPEnum::M_put, url, body, false, 0, 0); + run(); + return is_valid(); +} + +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::delete_document +// Access: Published +// Description: Requests the server to remove the indicated URL. +//////////////////////////////////////////////////////////////////// +INLINE bool HTTPChannel:: +delete_document(const URLSpec &url) { + begin_request(HTTPEnum::M_delete, url, string(), false, 0, 0); + run(); + return is_valid(); +} + +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::get_trace +// Access: Published +// Description: Sends a TRACE message to the server, which should +// return back the same message as the server received +// it, allowing inspection of proxy hops, etc. +//////////////////////////////////////////////////////////////////// +INLINE bool HTTPChannel:: +get_trace(const URLSpec &url) { + begin_request(HTTPEnum::M_trace, url, string(), false, 0, 0); + run(); + return is_valid(); +} + //////////////////////////////////////////////////////////////////// // Function: HTTPChannel::connect_to // Access: Published @@ -461,25 +500,6 @@ connect_to(const URLSpec &url) { return is_connection_ready(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_post_form -// Access: Published -// Description: Posts form data to a particular URL and retrieves the -// response, all using non-blocking I/O. See -// begin_get_document() and post_form(). -// -// It is important to note that you *must* call run() -// repeatedly after calling this method until run() -// returns false, and you may not call any other -// document posting or retrieving methods using the -// HTTPChannel object in the interim, or your form data -// may not get posted. -//////////////////////////////////////////////////////////////////// -INLINE void HTTPChannel:: -begin_post_form(const URLSpec &url, const string &body) { - begin_request(HTTPEnum::M_post, url, body, true, 0, 0); -} - //////////////////////////////////////////////////////////////////// // Function: HTTPChannel::begin_get_document // Access: Published @@ -527,6 +547,25 @@ begin_get_header(const URLSpec &url) { begin_request(HTTPEnum::M_head, url, string(), true, 0, 0); } +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::begin_post_form +// Access: Published +// Description: Posts form data to a particular URL and retrieves the +// response, all using non-blocking I/O. See +// begin_get_document() and post_form(). +// +// It is important to note that you *must* call run() +// repeatedly after calling this method until run() +// returns false, and you may not call any other +// document posting or retrieving methods using the +// HTTPChannel object in the interim, or your form data +// may not get posted. +//////////////////////////////////////////////////////////////////// +INLINE void HTTPChannel:: +begin_post_form(const URLSpec &url, const string &body) { + begin_request(HTTPEnum::M_post, url, body, true, 0, 0); +} + //////////////////////////////////////////////////////////////////// // Function: HTTPChannel::begin_connect_to // Access: Published diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index 2e3fc43046..5d06c93d8d 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -109,18 +109,21 @@ PUBLISHED: INLINE void reset(); - INLINE bool post_form(const URLSpec &url, const string &body); INLINE bool get_document(const URLSpec &url); INLINE bool get_subdocument(const URLSpec &url, size_t first_byte, size_t last_byte); INLINE bool get_header(const URLSpec &url); + INLINE bool post_form(const URLSpec &url, const string &body); + INLINE bool put_document(const URLSpec &url, const string &body); + INLINE bool delete_document(const URLSpec &url); + INLINE bool get_trace(const URLSpec &url); INLINE bool connect_to(const URLSpec &url); - INLINE void begin_post_form(const URLSpec &url, const string &body); INLINE void begin_get_document(const URLSpec &url); INLINE void begin_get_subdocument(const URLSpec &url, size_t first_byte, size_t last_byte); INLINE void begin_get_header(const URLSpec &url); + INLINE void begin_post_form(const URLSpec &url, const string &body); bool run(); INLINE void begin_connect_to(const URLSpec &url); diff --git a/panda/src/downloader/httpEnum.cxx b/panda/src/downloader/httpEnum.cxx index fb2e153901..1dbfed87c0 100644 --- a/panda/src/downloader/httpEnum.cxx +++ b/panda/src/downloader/httpEnum.cxx @@ -39,6 +39,18 @@ operator << (ostream &out, HTTPEnum::Method method) { out << "POST"; break; + case HTTPEnum::M_put: + out << "PUT"; + break; + + case HTTPEnum::M_delete: + out << "DELETE"; + break; + + case HTTPEnum::M_trace: + out << "TRACE"; + break; + case HTTPEnum::M_connect: out << "CONNECT"; break; diff --git a/panda/src/downloader/httpEnum.h b/panda/src/downloader/httpEnum.h index 09539d0e69..6c7146a8cb 100644 --- a/panda/src/downloader/httpEnum.h +++ b/panda/src/downloader/httpEnum.h @@ -47,7 +47,10 @@ public: M_get, M_head, M_post, - M_connect + M_put, + M_delete, + M_trace, + M_connect, }; };