[erlang-patches] Patch for packet_parser.c to Include HTTP Methods Defined in RFC 2518 / WebDAV

Jan Lehnardt <>
Mon Feb 9 00:47:52 CET 2009


Dear OTP Team,

the attached patch adds additional HTTP methods to packet_parser.c.
The methods are defined in RFC 2518 / WebDAV. While not part of the
HTTP/1.1 RFC 2616, these methods are useful when implementing
a WebDAV (or similar) server in Erlang.

I work on CouchDB. We borrowed the COPY and MOVE methods
(but not the others) from RFC 2518 to allow additional operations on
resources on the server. Until now, a parsed packet will include a
list /  string as the HTTP method if the method is not defined in
packet_parser.c and as an atom otherwise.

CouchDB uses this code to mitigate the issue:

   % Non standard HTTP verbs aren't atoms (COPY, MOVE etc) so convert  
when
   % possible (if any module references the atom, then it's existing).
   Meth -> couch_util:to_existing_atom(Meth)

couch_util:to_existing_atom/1 handles the case:

   % works like list_to_existing_atom, except can be list or binary  
and it
   % gives you the original value instead of an error if no existing  
atom.
   to_existing_atom(V) when is_list(V)->
       try list_to_existing_atom(V) catch _ -> V end;
   to_existing_atom(V) when is_binary(V)->
       try list_to_existing_atom(?b2l(V)) catch _ -> V end;
   to_existing_atom(V) when is_atom(V)->
       V.

CouchDB (and other implementors of HTTP extending standards) would
benefit from the inclusion of the methods in RFC 2518. While CouchDB
only needs COPY and MOVE (for now), adding the complete suite of
additional HTTP methods seems sensible. Please consider the patch
for inclusion into the next OTP release.

The patch is made against the preview release R13A but it equally
applies to R12B-5.

Cheers
Jan
--


--- a/erts/emulator/beam/packet_parser.c	2009-02-09 00:14:24.000000000  
+0100
+++ b/erts/emulator/beam/packet_parser.c	2009-02-09 00:12:56.000000000  
+0100
@@ -139,6 +139,13 @@
      "PUT",
      "DELETE",
      "TRACE",
+    "PROPFIND",
+    "PROPPATCH",
+    "MKCOL",
+    "COPY",
+    "MOVE",
+    "LOCK",
+    "UNLOCK",
      NULL
  };




More information about the erlang-patches mailing list