keybase
[m6w6/m6w6.github.io] / _posts / 2006-06-11-installing-peclhttp.md
1 ---
2 title: Installing pecl_http
3 author: m6w6
4 tags:
5 - PHP
6 ---
7
8 As [pecl/http](http://pecl.php.net/package/pecl_http) 1.0 has finally been
9 released and I had noticed that it's been packaged already by several projects
10 like PLD, Gentoo and FreeBSD, I wanted to explain what one is going to gain
11 respectively lose by using the different build/configure options for the
12 extension.
13
14 The help text of configure for pecl/http should look similar to the following:
15 ```
16 --enable-http Enable extended HTTP support
17 --with-http-curl-requests[=LIBCURLDIR]
18 HTTP: with cURL request support
19 --with-http-zlib-compression[=LIBZDIR]
20 HTTP: with zlib encodings support
21 --with-http-magic-mime[=LIBMAGICDIR]
22 HTTP: with magic mime response content type guessing
23 --with-http-shared-deps HTTP: disable to not depend on extensions like hash,
24 iconv and session (when built shared)
25 ```
26
27 If you link the extension source directory into your php tree, you should be
28 aware that these options show up on the end of the list of configure options
29 for **extensions** , not--as probably expected--in alphabetical order. This is
30 due to a recent change to use config9.m4 because the HTTP extension may depend
31 on several other PHP extensions ([hash](http://php.net/hash),
32 [iconv](http://php.net/iconv), [session](http://php.net/session)).
33
34
35 --with-http-curl-requests
36 : This configure option enables request functionality, uses
37 [libcurl](http://curl.haxx.se/libcurl/) and is _highly recommended_ to be
38 enabled. The minumum libcurl version required is 7.12.3. Debian/stable
39 currently ships 7.13.2 (no, this is not a typo).
40
41 --with-http-zlib-compression
42 : I think this is the most overseen/ignored option. Besides handling of
43 compressed HTTP messages, it also provides superior deflate/inflate
44 functionaly in regards to stability and performance compared to the standard
45 zlib extension. Both [http_deflate](http://dev.iworks.at/ext-http/http-functions.html.gz#http_deflate)()
46 /[http_inflate](http://dev.iworks.at/ext-http/http-functions.html.gz#http_inflate)() functions and
47 http.deflate/http.inflate stream filters are able to encode/decode all valid
48 gzip, zlib (AKA deflate) and raw deflated data. It requires at lieast libz
49 version 1.2.0.4, while Debian/stable ships 1.2.2, and is also _highly recommended_ to be enabled.
50
51
52
53 --with-http-magic-mime
54 : This option enables content type guessing for the
55 [HttpResponse](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpResponse)
56 and [HttpMessage](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpMessage)
57 classes. It's rather a gimmick and
58 thus not enabled by default. As there's no version information available for
59 libmagic, I don't even know which is the minimum version required but I guess
60 anything coming from a file-4.1x versioned package should work. If you get an
61 empty string as content type for payload which is obviously XML text, check
62 the magic.mime database you use for a broken **first** XML section. Comment
63 out everything except the SVG detection as other XML types and HTML is handled
64 further down the magic file (noticed on Debian systems). If you changed your
65 magic.mime database, don't forget to regenerate the precompiled version with
66 the `file -C` command.
67
68
69
70 --with-http-shared-deps
71 : This option controls whether pecl/http will depend on extensions built as
72 dynamically loadable modules. So, if e.g. ext/iconv has been compiled shared,
73 pecl/http relies on ext/iconv to be loaded when itself is going to be loaded.
74 This option is enabled by default.
75
76 * _ext/hash_
77 pecl/http uses ext/hash to generate ETag hashes (else standard PHP MD5, SHA1 or CRC32).
78 * _ext/iconv_
79 If ext/iconv is present, the [HttpQueryString](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpQueryString)
80 class provides an [xlate](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpQueryString_xlate)() method for charset transformation.
81 * _ext/session_
82 [http_redirect](http://dev.iworks.at/ext-http/http-functions.html.gz#http_redirect)() can
83 automatically append session information to the redirect URL.
84 * _ext/spl_
85 ext/spl cannot be built shared, so pecl/http always uses it if it's enabled.
86 [HttpMessage](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpMessage) and
87 [HttpRequestPool](http://dev.iworks.at/ext-http/http-functions.html.gz#HttpRequestPool)
88 classes implement the interface Countable provided by ext/spl.
89