diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/Portfile devel/caml-ocamlnet/Portfile
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/Portfile	2008-10-18 22:05:04.000000000 +0200
+++ devel/caml-ocamlnet/Portfile	2009-04-13 15:40:52.000000000 +0200
@@ -4,6 +4,7 @@
 
 name                caml-ocamlnet
 version             2.2.9
+revision            3
 categories          devel ml
 maintainers         landonf openmaintainer
 description         Internet protocols and helper data structures for OCaml.
@@ -29,6 +30,10 @@
                     port:caml-findlib \
                     port:caml-pcre
 
+patchfiles          patch-http_client.ml.diff patch-rpc_transport.ml.diff \
+                    patch-uq_engines.ml.diff patch-nethttpd_kernel.ml.diff \
+                    patch-netstring_nethttp.ml.diff patch-http_client.mli.diff
+
 post-patch {
     set ocaml_site_path [exec ocamlfind printconf destdir]
     reinplace       "s|\$(OCAMLFIND) install|\$(OCAMLFIND) install -destdir ${destroot}/${ocaml_site_path}|g" \
@@ -36,7 +41,7 @@
 }
 
 configure {
-    system "cd ${worksrcpath} && ./configure"
+    system "cd ${worksrcpath} && ./configure -with-nethttpd"
 }
 
 build.target        all opt
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-http_client.ml.diff devel/caml-ocamlnet/files/patch-http_client.ml.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-http_client.ml.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-http_client.ml.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,27 @@
+--- src/netclient/http_client.ml.orig	2009-03-18 16:59:19.000000000 +0000
++++ src/netclient/http_client.ml	2009-03-19 00:41:06.000000000 +0000
+@@ -1567,7 +1567,7 @@
+ 	      if not (List.mem fd fd_list) then
+ 		Hashtbl.replace rev_inactive_conns peer (fd :: fd_list)
+ 	    with
+-	      | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
++	      | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
+ 		  self # forget_connection fd
+ 	  )
+ 
+@@ -4461,6 +4461,15 @@
+ 
+     let http_post url params = (http_post_message url params) # get_resp_body()
+ 
++    let http_post_raw_message ?(callfn=(fun _ -> ())) url raw_param =
++      let m = new post_raw (prepare_url url) raw_param in
++      callfn m;
++      request m 1;
++      m
++
++    let http_post_raw ?(callfn=(fun _ -> ())) url raw_param = 
++      (http_post_raw_message ~callfn url raw_param) # get_resp_body()
++    
+     let http_put_message url content =
+       let m = new put (prepare_url url) content in
+       request m !http_trials;
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-http_client.mli.diff devel/caml-ocamlnet/files/patch-http_client.mli.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-http_client.mli.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-http_client.mli.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,37 @@
+--- src/netclient/http_client.mli.orig	2009-03-18 15:26:57.000000000 +0000
++++ src/netclient/http_client.mli	2009-03-19 00:40:15.000000000 +0000
+@@ -1094,6 +1094,13 @@
+       * The list contains the parameters sent with the POST request.
+       *)
+ 
++  val http_post_raw_message: ?callfn:(post_raw -> unit) -> string -> string -> http_call
++    (** Does a "POST" request with the given raw body and returns the reply.
++      * The string contains the raw message body sent with the POST request.
++      * If specified, callfn is applied to the underlying post_raw object before
++      * the request is sent (e.g. to add a custom HTTP header).
++      *)
++
+   val http_put_message : string -> string -> http_call
+     (** Does a "PUT" request with the given URL and returns the reply.
+       * The second argument contains the contents to be put.
+@@ -1112,6 +1119,12 @@
+       * The list contains the parameters send with the POST request.
+      *)
+ 
++  val http_post_raw : ?callfn:(post_raw -> unit) -> string -> string -> string
++    (** Does a "POST" request with the given raw body and returns the reply.
++      * The string contains the raw message body sent with the POST request.
++      * If specified, callfn is applied to the underlying post_raw object before
++      * the request is sent (e.g. to add a custom HTTP header) *)
++
+   val http_put : string -> string -> string
+     (** Does a "PUT" request with the given URL and returns the response body.
+       * The second argument contains the contents to be put.
+@@ -1124,7 +1137,6 @@
+ 
+   val http_verbose : unit -> unit
+     (** Turns on debug messages on stderr. *)
+-
+ end
+ 
+ (**/**)
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-nethttpd_kernel.ml.diff devel/caml-ocamlnet/files/patch-nethttpd_kernel.ml.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-nethttpd_kernel.ml.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-nethttpd_kernel.ml.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,15 @@
+--- src/nethttpd-for-netcgi1/nethttpd_kernel.ml.orig	2007-11-01 22:12:31.000000000 +0000
++++ src/nethttpd-for-netcgi1/nethttpd_kernel.ml	2009-02-04 21:39:19.000000000 +0000
+@@ -249,9 +249,9 @@
+ 		  transfer_encoding <- `Identity;
+ 	  );
+ 	  (* Update the header: *)
+-	  ( match transfer_encoding with
+-	      | `Identity -> resp_header # delete_field "Transfer-Encoding"
+-	      | `Chunked  -> set_transfer_encoding resp_header ["chunked", []]
++	  ( match transfer_encoding, suppress_body with
++	      | `Identity,false | _,true -> resp_header # delete_field "Transfer-Encoding"
++	      | `Chunked,false -> set_transfer_encoding resp_header ["chunked", []]
+ 	  );
+ 	  resp_header # delete_field "Trailer";
+ 	  set_date resp_header (Unix.time());
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-netstring_nethttp.ml.diff devel/caml-ocamlnet/files/patch-netstring_nethttp.ml.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-netstring_nethttp.ml.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-netstring_nethttp.ml.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,22 @@
+--- src/netstring/nethttp.ml.orig	2009-03-03 02:59:38.000000000 +0000
++++ src/netstring/nethttp.ml	2009-03-03 03:00:25.000000000 +0000
+@@ -353,15 +353,16 @@
+   let l' = List.map (Netencoding.Url.encode ~plus:false) l in
+   Neturl.join_path l'
+ 
+-let uripath_decode s =
++let rec uripath_decode s =
+   let l = Neturl.split_path s in
+   let l' = 
+     List.map
+       (fun u -> 
+ 	 let u' = Netencoding.Url.decode ~plus:false u in
+ 	 if String.contains u' '/' then
+-	   failwith "Nethttp.uripath_decode";
+-	 u')
++             uripath_decode u'
++         else
++             u')
+       l in
+   Neturl.join_path l'
+ 
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-rpc_transport.ml.diff devel/caml-ocamlnet/files/patch-rpc_transport.ml.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-rpc_transport.ml.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-rpc_transport.ml.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,24 @@
+--- src/rpc/rpc_transport.ml.orig	2009-02-03 16:13:34.000000000 +0000
++++ src/rpc/rpc_transport.ml	2009-02-03 16:16:50.000000000 +0000
+@@ -236,7 +236,7 @@
+     with
+       | Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP),_,_) -> 
+ 	  Some `Implied
+-      | Unix.Unix_error(Unix.ENOTCONN,_,_) -> 
++      | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) -> 
+ 	  (* ENOTCONN is special because we allow to set the peer address
+              per datagram in this case!
+            *)
+@@ -552,9 +552,10 @@
+       `Sockaddr(Unix.getpeername fd)
+     with
+ 	(* also catching ENOTCONN - which might happen for strange socket
+-           implementations
++           implementations. EINVAL is thrown on MacOS 10.5 instead of ENOTCONN
+          *)
+-      | Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP|Unix.ENOTSOCK|Unix.ENOTCONN),
++      | Unix.Unix_error((Unix.EAFNOSUPPORT|Unix.EOPNOTSUPP|Unix.ENOTSOCK|
++                         Unix.ENOTCONN|Unix.EINVAL),
+ 			_,_) -> `Implied in
+   let mplex = 
+     Uq_engines.create_multiplex_controller_for_connected_socket
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-uq_engines.ml.diff devel/caml-ocamlnet/files/patch-uq_engines.ml.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/caml-ocamlnet/files/patch-uq_engines.ml.diff	1970-01-01 01:00:00.000000000 +0100
+++ devel/caml-ocamlnet/files/patch-uq_engines.ml.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,38 @@
+--- src/equeue/uq_engines.ml.orig	2009-02-03 16:17:18.000000000 +0000
++++ src/equeue/uq_engines.ml	2009-02-03 16:18:51.000000000 +0000
+@@ -1456,7 +1456,7 @@
+       (* fd is a connected socket *)
+       `Recv_send addr
+     with
+-      | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
++      | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
+ 	  (* fd is an unconnected socket *)
+ 	  `Recvfrom_sendto
+       | Unix.Unix_error(Unix.ENOTSOCK,_,_) -> 
+@@ -2329,7 +2329,7 @@
+ 		  ignore(Unix.getpeername s); 
+ 		  `Done(`Socket(s, getsockspec stype s))
+ 		with
+-		  | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
++		  | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
+ 		      (* We did not succeed connecting. ENOTCONN is just a
+                        * substitute error code, not the real error, however.
+                        *)
+@@ -2349,7 +2349,7 @@
+ 			       ignore(Unix.getpeername s); 
+ 			       `Done(`Socket(s, getsockspec stype s))
+ 			     with
+-			       | Unix.Unix_error(Unix.ENOTCONN,_,_) ->
++			       | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) ->
+ 				   (* See comment above *)
+ 				   `Error (getconnerror s)
+ 			       | error -> 
+@@ -2503,7 +2503,7 @@
+ 		       let ps =
+ 			 try getpeerspec Unix.SOCK_STREAM sock'
+ 			 with
+-			   | Unix.Unix_error(Unix.ENOTCONN,_,_) as e ->
++			   | Unix.Unix_error((Unix.ENOTCONN|Unix.EINVAL),_,_) as e ->
+ 			       Unix.close sock';
+ 			       raise e in
+ 		       acc_engine <- None;

