-http_client.cmo: http_common.cmi http_misc.cmi http_parser.cmi \
- http_client.cmi
-http_client.cmx: http_common.cmx http_misc.cmx http_parser.cmx \
- http_client.cmi
http_common.cmo: http_constants.cmi http_types.cmo http_common.cmi
http_common.cmx: http_constants.cmx http_types.cmx http_common.cmi
http_constants.cmo: http_constants.cmi
http_message.cmx http_misc.cmx http_types.cmx http_response.cmi
http_tcp_server.cmo: http_threaded_tcp_server.cmi http_tcp_server.cmi
http_tcp_server.cmx: http_threaded_tcp_server.cmi http_tcp_server.cmi
+http_user_agent.cmo: http_common.cmi http_misc.cmi http_parser.cmi \
+ http_user_agent.cmi
+http_user_agent.cmx: http_common.cmx http_misc.cmx http_parser.cmx \
+ http_user_agent.cmi
http_common.cmi: http_types.cmo
http_constants.cmi: http_types.cmo
http_daemon.cmi: http_types.cmo
MODULES = \
http_types http_constants http_parser_sanity http_misc http_common \
http_tcp_server http_parser http_message http_request http_daemon \
- http_response http_client
+ http_response http_user_agent
THREADED_SRV = http_threaded_tcp_server
MODULES_MT = $(patsubst http_tcp_server, mt/$(THREADED_SRV) http_tcp_server, $(MODULES))
MODULES_NON_MT = $(patsubst http_tcp_server, non_mt/$(THREADED_SRV) http_tcp_server, $(MODULES))
PUBLIC_MODULES = \
http_common http_message http_request http_daemon http_response \
- http_client
+ http_user_agent
PUBLIC_IMPL = http_types
OCAMLDOC_STUFF = *.mli $(patsubst %, %.ml, $(PUBLIC_IMPL))
DOCDIR = doc/html
ocaml-http (0.0.10) unstable; urgency=low
- * rebuilt for ocaml 3.08
+ * renamed Http_client module to Http_user_agent to avoid compatibility
+ issues with Netclient. Renamed that module functions removing
+ "http_" prefix (e.g., summarizing, Http_client.http_get ->
+ Http_user_agent.get)
+ * ported to ocaml 3.08
* debian/control
- bumped standards version to 3.6.1.1
- changed deps to ocaml 3.08 and -nox
+++ /dev/null
-
-(*
- OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
-
- Copyright (C) <2002-2004> Stefano Zacchiroli <zack@cs.unibo.it>
-
- 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 Printf
-
-open Http_common
-
-exception Http_error of (int * string) (* code, body *)
-
-let http_scheme_RE = Pcre.regexp ~flags:[`CASELESS] "^http://"
-let url_RE = Pcre.regexp "^([\\w.-]+)(:(\\d+))?(/.*)?$"
-
-let tcp_bufsiz = 4096 (* for TCP I/O *)
-
-let parse_url url =
- try
- let subs =
- Pcre.extract ~rex:url_RE (Pcre.replace ~rex:http_scheme_RE url)
- in
- (subs.(1),
- (if subs.(2) = "" then 80 else int_of_string subs.(3)),
- (if subs.(4) = "" then "/" else subs.(4)))
- with exc ->
- failwith
- (sprintf "Can't parse url: %s (exception: %s)"
- url (Printexc.to_string exc))
-
-let init_socket addr port =
- let inet_addr = (Unix.gethostbyname addr).Unix.h_addr_list.(0) in
- let sockaddr = Unix.ADDR_INET (inet_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
- let inchan = Unix.in_channel_of_descr suck in
- (inchan, outchan)
-
-let submit_request kind url =
- let (address, port, path) = parse_url url in
- let (inchan, outchan) = init_socket address port in
- let req_string = match kind with `GET -> "GET" | `HEAD -> "HEAD" in
- output_string outchan (sprintf "%s %s HTTP/1.0\r\n" req_string path);
- output_string outchan (sprintf "Host: %s\r\n\r\n" address);
- flush outchan;
- (inchan, outchan)
-
-let http_head url =
- let (inchan, outchan) = submit_request `HEAD url in
- let (_, status) = Http_parser.parse_response_fst_line inchan in
- (match code_of_status status with
- | 200 -> ()
- | code -> raise (Http_error (code, "")));
- let buf = Http_misc.buf_of_inchan inchan in
- close_in inchan; (* close also outchan, same fd *)
- Buffer.contents buf
-
-let http_get_iter callback url =
- let (inchan, outchan) = submit_request `GET url in
- let buf = String.create tcp_bufsiz in
- let (_, status) = Http_parser.parse_response_fst_line inchan in
- (match code_of_status status with
- | 200 -> ()
- | code -> raise (Http_error (code, "")));
- ignore (Http_parser.parse_headers inchan);
- (try
- while true do
- match input inchan buf 0 tcp_bufsiz with
- | 0 -> raise End_of_file
- | bytes when bytes = tcp_bufsiz -> (* buffer full, no need to slice it *)
- callback buf
- | bytes when bytes < tcp_bufsiz -> (* buffer not full, slice it *)
- callback (String.sub buf 0 bytes)
- | _ -> (* ( bytes < 0 ) || ( bytes > tcp_bufsiz ) *)
- assert false
- done
- with End_of_file -> ());
- close_in inchan (* close also outchan, same fd *)
-
-let http_get url =
- let buf = Buffer.create 10240 in
- http_get_iter (Buffer.add_string buf) url;
- Buffer.contents buf
-
+++ /dev/null
-
-(*
- OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
-
- Copyright (C) <2002-2004> Stefano Zacchiroli <zack@cs.unibo.it>
-
- 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
-*)
-
-(** Minimal implementation of an HTTP 1.0/1.1 client. Interface is similar to
- * Gerd Stoplmann's Http_client module. Implementation is simpler and doesn't
- * handle HTTP redirection, proxies, ecc. The only reason for the existence of
- * this module is for performances and incremental elaboration of response's
- * bodies *)
-
-exception Http_error of (int * string) (* code, body *)
-
- (** @param url an HTTP url
- * @return HTTP response's body
- * @raise Http_error when response code <> 200 *)
-val http_get: string -> string
-
- (** as above but iter callback function on HTTP response's body instead of
- * returning it as a string *)
-val http_get_iter: (string -> unit) -> string -> unit
-
- (** @param url an HTTP url
- * @return HTTP HEAD raw response
- * @raise Http_error when response code <> 200 *)
-val http_head: string -> string
-
--- /dev/null
+
+(*
+ OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
+
+ Copyright (C) <2002-2004> Stefano Zacchiroli <zack@cs.unibo.it>
+
+ 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 Printf
+
+open Http_common
+
+exception Http_error of (int * string) (* code, body *)
+
+let http_scheme_RE = Pcre.regexp ~flags:[`CASELESS] "^http://"
+let url_RE = Pcre.regexp "^([\\w.-]+)(:(\\d+))?(/.*)?$"
+
+let tcp_bufsiz = 4096 (* for TCP I/O *)
+
+let parse_url url =
+ try
+ let subs =
+ Pcre.extract ~rex:url_RE (Pcre.replace ~rex:http_scheme_RE url)
+ in
+ (subs.(1),
+ (if subs.(2) = "" then 80 else int_of_string subs.(3)),
+ (if subs.(4) = "" then "/" else subs.(4)))
+ with exc ->
+ failwith
+ (sprintf "Can't parse url: %s (exception: %s)"
+ url (Printexc.to_string exc))
+
+let init_socket addr port =
+ let inet_addr = (Unix.gethostbyname addr).Unix.h_addr_list.(0) in
+ let sockaddr = Unix.ADDR_INET (inet_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
+ let inchan = Unix.in_channel_of_descr suck in
+ (inchan, outchan)
+
+let submit_request kind url =
+ let (address, port, path) = parse_url url in
+ let (inchan, outchan) = init_socket address port in
+ let req_string = match kind with `GET -> "GET" | `HEAD -> "HEAD" in
+ output_string outchan (sprintf "%s %s HTTP/1.0\r\n" req_string path);
+ output_string outchan (sprintf "Host: %s\r\n\r\n" address);
+ flush outchan;
+ (inchan, outchan)
+
+let head url =
+ let (inchan, outchan) = submit_request `HEAD url in
+ let (_, status) = Http_parser.parse_response_fst_line inchan in
+ (match code_of_status status with
+ | 200 -> ()
+ | code -> raise (Http_error (code, "")));
+ let buf = Http_misc.buf_of_inchan inchan in
+ close_in inchan; (* close also outchan, same fd *)
+ Buffer.contents buf
+
+let get_iter callback url =
+ let (inchan, outchan) = submit_request `GET url in
+ let buf = String.create tcp_bufsiz in
+ let (_, status) = Http_parser.parse_response_fst_line inchan in
+ (match code_of_status status with
+ | 200 -> ()
+ | code -> raise (Http_error (code, "")));
+ ignore (Http_parser.parse_headers inchan);
+ (try
+ while true do
+ match input inchan buf 0 tcp_bufsiz with
+ | 0 -> raise End_of_file
+ | bytes when bytes = tcp_bufsiz -> (* buffer full, no need to slice it *)
+ callback buf
+ | bytes when bytes < tcp_bufsiz -> (* buffer not full, slice it *)
+ callback (String.sub buf 0 bytes)
+ | _ -> (* ( bytes < 0 ) || ( bytes > tcp_bufsiz ) *)
+ assert false
+ done
+ with End_of_file -> ());
+ close_in inchan (* close also outchan, same fd *)
+
+let get url =
+ let buf = Buffer.create 10240 in
+ get_iter (Buffer.add_string buf) url;
+ Buffer.contents buf
+
--- /dev/null
+
+(*
+ OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
+
+ Copyright (C) <2002-2004> Stefano Zacchiroli <zack@cs.unibo.it>
+
+ 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
+*)
+
+(** Minimal implementation of an HTTP 1.0/1.1 client. Interface is similar to
+ * Gerd Stoplmann's Http_client module. Implementation is simpler and doesn't
+ * handle HTTP redirection, proxies, ecc. The only reason for the existence of
+ * this module is for performances and incremental elaboration of response's
+ * bodies *)
+
+exception Http_error of (int * string) (* code, body *)
+
+ (** @param url an HTTP url
+ * @return HTTP response's body
+ * @raise Http_error when response code <> 200 *)
+val get: string -> string
+
+ (** as above but iter callback function on HTTP response's body instead of
+ * returning it as a string *)
+val get_iter: (string -> unit) -> string -> unit
+
+ (** @param url an HTTP url
+ * @return HTTP HEAD raw response
+ * @raise Http_error when response code <> 200 *)
+val head: string -> string
+