1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
This is a true HTTP 1.1 client. See http_client.mli for details.
The installation of this client is "findlib"-based. "findlib" is a
simple library that organizes the installation of "packages", i.e.
collections of ocaml modules. (The client works without "findlib",
but you have to heavily modify the Makefile.)
You need the following packages:
- netstring
If you want support for multi-threaded applications, you need
additionally
- xstr
You find "findlib" and the packages in the Ocaml link database,
http://www.npc.de/ocaml/linkdb/
Note that there is online documentation for "findlib":
http://www.ocaml-programming.de/packages/findlib/
------------------------------------------------------------------------
Installation:
------------------------------------------------------------------------
- It is assumed that "findlib" and "netstring" are properly installed.
(And "xstr" if you want MT-support.)
- Do
make all
to compile with the bytecode compiler. This creates netclient.cma and
netclient_mt.cma, the library variant for multi-threading.
Important note if you have Ocaml-3.06 or earlier, and not yet 3.07:
Use
make all BYTE_THREAD=-thread
instead (there is no -vmthread option).
If you do not want multi-threading at all, compile with
make non_mt
- Do
make non_mt_opt
to compile with the native compiler if present. This creates netclient.cmxa.
If your O'Caml installation supports POSIX threads, you can also do
make opt
to get the thread-safe variant, too (netclient_mt.cmxa).
- Do
make install
to install.
- Do
make uninstall
to uninstall.
------------------------------------------------------------------------
How to link in netclient.cma:
------------------------------------------------------------------------
To link something which uses netclient.cma, use the following command
which demonstrates how to link:
ocamlfind ocamlc -o output
-package netclient -linkpkg
<your objects>
SUPPORT FOR MULTI-THREADING:
This is simply enabled by giving the -thread (or -vmthread) option, e.g.
ocamlfind ocamlc -thread -o output -package netclient -linkpkg
<your objects>
------------------------------------------------------------------------
Example:
------------------------------------------------------------------------
To run the examples in examples/simple, you need a toploop as follows:
ocamlfind ocamlmktop -o top -package unix,str -linkpkg
The other examples have Makefiles.
------------------------------------------------------------------------
New Convenience Module
------------------------------------------------------------------------
From release 0.2, there is a convenience module which simplifies the
usage of the client.
- open the module:
open Http_client.Convenience;;
- get the result in one step:
http_get "http://somewhere.com/file"
The convenience module also interprets the environment variables
http_proxy and no_proxy. Furthermore, user and password can be
given directly in the URL (http://user:password@location.domain/path).
------------------------------------------------------------------------
RESTRICTED MULTI-THREADING SAFETY
------------------------------------------------------------------------
If used in a certain way, release 0.3 of "netclient" is thread-safe.
See the comment in "http_client.mli" for details.
------------------------------------------------------------------------
Restrictions
------------------------------------------------------------------------
- Some rarely used features of HTTP/1.1 have not been implemented,
such as multipart messages.
- Some features of HTTP/1.1 are not supported by this module, but can
be implemented on top of it:
content encoding, content digests, conditional/partial GET, caching
A lot of fun!
Author:
Gerd Stolpmann, gerd@gerd-stolpmann.de
----------------------------------------------------------------------
History
----------------------------------------------------------------------
0.90.4: Removed dependency on the module "Cgi" (deprecated)
0.90.3: Fixing bugs in Makefile for O'Caml 3.07
0.90.2: Fixed a problem with incomplete status lines (e.g.
"HTTP/1.1 500" instead of "HTTP/1.1 500 Server Error").
0.90.1: ???
0.90: Rewritten Http_client in event-driven way.
Added Telnet_client.
|