Explorar el Código

add OPTIONS method

David Rose hace 23 años
padre
commit
b0fbd85234

+ 14 - 0
panda/src/downloader/httpChannel.I

@@ -590,6 +590,20 @@ connect_to(const DocumentSpec &url) {
   return is_connection_ready();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: HTTPChannel::get_options
+//       Access: Published
+//  Description: Sends an OPTIONS message to the server, which should
+//               query the available options, possibly in relation to
+//               a specified URL.
+////////////////////////////////////////////////////////////////////
+INLINE bool HTTPChannel::
+get_options(const DocumentSpec &url) {
+  begin_request(HTTPEnum::M_options, url, string(), false, 0, 0);
+  run();
+  return is_valid();
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: HTTPChannel::begin_get_document
 //       Access: Published

+ 7 - 0
panda/src/downloader/httpChannel.cxx

@@ -2306,6 +2306,13 @@ make_header() {
     request_path = _request.get_url().get_path();
   }
 
+  // HTTP syntax always requires something in the request path.  If it
+  // is empty, put in a star as a placeholder (OPTIONS, for instance,
+  // uses this).
+  if (request_path.empty()) {
+    request_path = "*";
+  }
+
   ostringstream stream;
 
   stream 

+ 1 - 0
panda/src/downloader/httpChannel.h

@@ -126,6 +126,7 @@ PUBLISHED:
   INLINE bool delete_document(const DocumentSpec &url);
   INLINE bool get_trace(const DocumentSpec &url);
   INLINE bool connect_to(const DocumentSpec &url);
+  INLINE bool get_options(const DocumentSpec &url);
 
   INLINE void begin_get_document(const DocumentSpec &url);
   INLINE void begin_get_subdocument(const DocumentSpec &url, 

+ 4 - 0
panda/src/downloader/httpEnum.cxx

@@ -27,6 +27,10 @@
 ostream &
 operator << (ostream &out, HTTPEnum::Method method) {
   switch (method) {
+  case HTTPEnum::M_options:
+    out << "OPTIONS";
+    break;
+
   case HTTPEnum::M_get:
     out << "GET";
     break;

+ 1 - 0
panda/src/downloader/httpEnum.h

@@ -44,6 +44,7 @@ public:
   };
 
   enum Method {
+    M_options,
     M_get,
     M_head,
     M_post,