X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2FDEVEL%2Focaml-http%2Fexamples%2Fdamned_recursion.ml;fp=helm%2FDEVEL%2Focaml-http%2Fexamples%2Fdamned_recursion.ml;h=0000000000000000000000000000000000000000;hp=dd3f6a36d0cc5410ec655cfc488421b76f5840e3;hb=3ef089a4c58fbe429dd539af6215991ecbe11ee2;hpb=1c7fb836e2af4f2f3d18afd0396701f2094265ff diff --git a/helm/DEVEL/ocaml-http/examples/damned_recursion.ml b/helm/DEVEL/ocaml-http/examples/damned_recursion.ml deleted file mode 100644 index dd3f6a36d..000000000 --- a/helm/DEVEL/ocaml-http/examples/damned_recursion.ml +++ /dev/null @@ -1,58 +0,0 @@ - -(* - OCaml HTTP - do it yourself (fully OCaml) HTTP daemon - - Copyright (C) <2002> Stefano Zacchiroli - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*) - -open Http_types;; -open Printf;; - -let wget addr port path = - let rec wget' inchan buf = - Buffer.add_string buf (input_line inchan ^ "\n"); - wget' inchan buf - in - prerr_endline (sprintf "DEBUG: wgetting url '%s:%d%s'" addr port path); - let sockaddr = Unix.ADDR_INET (Unix.inet_addr_of_string addr, port) in - let suck = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in - Unix.connect suck sockaddr; - let outchan = Unix.out_channel_of_descr suck in - output_string outchan (sprintf "GET %s HTTP/1.0\r\n\r\n" path); - flush outchan; - let inchan = Unix.in_channel_of_descr suck in - let buf = Buffer.create 1023 in - try - wget' inchan buf - with End_of_file -> Buffer.contents buf -in -let callback (req: request) outchan = - let i = int_of_string (req#param "x") in - prerr_endline (string_of_int i); - match i with - | 0 -> output_string outchan "1" - | x when x>0 -> - let data = - wget "127.0.0.1" 9999 (sprintf "/foo?x=%d" (x-1)) -(* wget "127.0.0.1" 80 "/index.html" *) - in - output_string outchan (sprintf "%s %d" data x) - | _ -> assert false -in -let mode = `Thread in -Http_daemon.start' ~port:9999 ~mode callback -