- using Accept-Encoding header instead of CURLOPT_ENCODING avoids issues with curl...
authorMichael Wallner <mike@php.net>
Wed, 14 Dec 2005 22:02:35 +0000 (22:02 +0000)
committerMichael Wallner <mike@php.net>
Wed, 14 Dec 2005 22:02:35 +0000 (22:02 +0000)
- there's no EGREP in WONKY's configure (?)
- only cache string request options
- CURLOPT_HTTPHEADER was lost

KnownIssues.txt
config.m4
config.w32
http_request_api.c
package2.xml

index 1192ba3..adfcfe3 100644 (file)
@@ -9,9 +9,6 @@ Not all places where files are handled check for open_basedir and/or safe_mode.
 If you keep getting "SSL connect error" when trying to issue requests on
 Windows, try another (newer) libeay32.dll/ssleay32.dll pair.
 
 If you keep getting "SSL connect error" when trying to issue requests on
 Windows, try another (newer) libeay32.dll/ssleay32.dll pair.
 
-Inflating compressed HttpRequest responses happens twice if libcurl
-was built with zlib support.
-
 Internals:
        -       there's a memleak with sizeof(zval) for each thrown exception, 
                which ends up in HttpRequestPoolExcepiont::$exceptionStack, in 
 Internals:
        -       there's a memleak with sizeof(zval) for each thrown exception, 
                which ends up in HttpRequestPoolExcepiont::$exceptionStack, in 
index 8d033b1..bf19c24 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -16,7 +16,11 @@ PHP_ARG_WITH([http-zlib-compression], [whether to enable support for gzencoded/d
 
 if test "$PHP_HTTP" != "no"; then
 
 
 if test "$PHP_HTTP" != "no"; then
 
-       AC_PROG_EGREP
+       ifdef([AC_PROG_EGREP], [
+               AC_PROG_EGREP
+       ], [
+               AC_CHECK_PROG(EGREP, egrep, egrep)
+       ])
        ifdef([AC_PROG_SED], [
                AC_PROG_SED
        ], [
        ifdef([AC_PROG_SED], [
                AC_PROG_SED
        ], [
@@ -98,11 +102,6 @@ dnl ----
                
                CURL_LIBS=`$CURL_CONFIG --libs`
                
                
                CURL_LIBS=`$CURL_CONFIG --libs`
                
-               CURL_ZLIB=`$CURL_CONFIG --features | $EGREP libz`
-               if test "$CURL_ZLIB" = "libz"; then
-                       AC_DEFINE([HTTP_HAVE_CURL_ZLIB], [1], [ ])
-               fi
-               
                AC_MSG_CHECKING([for SSL support in libcurl])
                CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
                if test "$CURL_SSL" = "SSL"; then
                AC_MSG_CHECKING([for SSL support in libcurl])
                CURL_SSL=`$CURL_CONFIG --features | $EGREP SSL`
                if test "$CURL_SSL" = "SSL"; then
index cc7a938..10bb196 100644 (file)
@@ -90,7 +90,6 @@ if (PHP_HTTP != "no") {
                        CHECK_LIB("zlib.lib", "http", PHP_HTTP) &&
                        CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {
                AC_DEFINE("HTTP_HAVE_CURL", 1, "Have CURL library");
                        CHECK_LIB("zlib.lib", "http", PHP_HTTP) &&
                        CHECK_LIB("winmm.lib", "http", PHP_HTTP)) {
                AC_DEFINE("HTTP_HAVE_CURL", 1, "Have CURL library");
-               AC_DEFINE("HTTP_HAVE_CURL_ZLIB", 1, "");
                AC_DEFINE("HTTP_HAVE_SSL", 1, "Have SSL");
                AC_DEFINE("HAVE_CURL_MULTI_STRERROR", 1, "");
                AC_DEFINE("HAVE_CURL_EASY_STRERROR", 1, "");
                AC_DEFINE("HTTP_HAVE_SSL", 1, "Have SSL");
                AC_DEFINE("HAVE_CURL_MULTI_STRERROR", 1, "");
                AC_DEFINE("HAVE_CURL_EASY_STRERROR", 1, "");
index 3408812..34126d8 100644 (file)
@@ -315,7 +315,7 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(PORT, 0);
                HTTP_CURL_OPT(USERPWD, NULL);
                HTTP_CURL_OPT(HTTPAUTH, 0);
                HTTP_CURL_OPT(PORT, 0);
                HTTP_CURL_OPT(USERPWD, NULL);
                HTTP_CURL_OPT(HTTPAUTH, 0);
-               HTTP_CURL_OPT(ENCODING, 0);
+               HTTP_CURL_OPT(ENCODING, NULL);
                HTTP_CURL_OPT(FOLLOWLOCATION, 0);
                HTTP_CURL_OPT(UNRESTRICTED_AUTH, 0);
                HTTP_CURL_OPT(REFERER, NULL);
                HTTP_CURL_OPT(FOLLOWLOCATION, 0);
                HTTP_CURL_OPT(UNRESTRICTED_AUTH, 0);
                HTTP_CURL_OPT(REFERER, NULL);
@@ -351,9 +351,6 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(IOCTLDATA, NULL);
                HTTP_CURL_OPT(READDATA, NULL);
                HTTP_CURL_OPT(INFILESIZE, 0);
                HTTP_CURL_OPT(IOCTLDATA, NULL);
                HTTP_CURL_OPT(READDATA, NULL);
                HTTP_CURL_OPT(INFILESIZE, 0);
-#if 0
-               HTTP_CURL_OPT(IGNORE_CONTENT_ENCODING, 1);
-#endif
        }
 }
 /* }}} */
        }
 }
 /* }}} */
@@ -430,15 +427,6 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                HTTP_CURL_OPT(HTTPAUTH, Z_LVAL_P(zoption));
        }
 
                HTTP_CURL_OPT(HTTPAUTH, Z_LVAL_P(zoption));
        }
 
-       /* compress, empty string enables all supported if libcurl was build with zlib support */
-       if ((zoption = http_request_option(request, options, "compress", IS_BOOL)) && Z_LVAL_P(zoption)) {
-#ifdef HTTP_HAVE_CURL_ZLIB
-               HTTP_CURL_OPT(ENCODING, "gzip, deflate");
-#else
-               HTTP_CURL_OPT(ENCODING, "gzip;q=1.0, deflate;q=0.5, *;q=0.1");
-#endif
-       }
-
        /* redirects, defaults to 0 */
        if ((zoption = http_request_option(request, options, "redirect", IS_LONG))) {
                HTTP_CURL_OPT(FOLLOWLOCATION, Z_LVAL_P(zoption) ? 1 : 0);
        /* redirects, defaults to 0 */
        if ((zoption = http_request_option(request, options, "redirect", IS_LONG))) {
                HTTP_CURL_OPT(FOLLOWLOCATION, Z_LVAL_P(zoption) ? 1 : 0);
@@ -459,16 +447,15 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        }
 
        /* additional headers, array('name' => 'value') */
        }
 
        /* additional headers, array('name' => 'value') */
+       if (request->_cache.headers) {
+               curl_slist_free_all(request->_cache.headers);
+               request->_cache.headers = NULL;
+       }
        if ((zoption = http_request_option(request, options, "headers", IS_ARRAY))) {
                char *header_key;
                ulong header_idx;
                HashPosition pos;
 
        if ((zoption = http_request_option(request, options, "headers", IS_ARRAY))) {
                char *header_key;
                ulong header_idx;
                HashPosition pos;
 
-               if (request->_cache.headers) {
-                       curl_slist_free_all(request->_cache.headers);
-                       request->_cache.headers = NULL;
-               }
-               
                FOREACH_KEY(pos, zoption, header_key, header_idx) {
                        if (header_key) {
                                zval **header_val;
                FOREACH_KEY(pos, zoption, header_key, header_idx) {
                        if (header_key) {
                                zval **header_val;
@@ -489,6 +476,10 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                        }
                }
        }
                        }
                }
        }
+       if ((zoption = http_request_option(request, options, "compress", IS_BOOL)) && Z_LVAL_P(zoption)) {
+               request->_cache.headers = curl_slist_append(request->_cache.headers, "Accept-Encoding: gzip;q=1.0,deflate;q=0.5,*;q=0.1");
+       }
+       HTTP_CURL_OPT(HTTPHEADER, request->_cache.headers);
 
        /* cookies, array('name' => 'value') */
        if ((zoption = http_request_option(request, options, "cookies", IS_ARRAY))) {
 
        /* cookies, array('name' => 'value') */
        if ((zoption = http_request_option(request, options, "cookies", IS_ARRAY))) {
@@ -863,14 +854,17 @@ static inline zval *_http_request_option_ex(http_request *r, HashTable *options,
                }
        }
        
                }
        }
        
-       ZVAL_ADDREF(*zoption);
+       /* cache strings */
+       if (type == IS_STRING) {
+               ZVAL_ADDREF(*zoption);
 #ifdef ZEND_ENGINE_2
 #ifdef ZEND_ENGINE_2
-       _zend_hash_quick_add_or_update(&r->_cache.options, key, keylen, h, zoption, sizeof(zval *), NULL, 
-               zend_hash_quick_exists(&r->_cache.options, key, keylen, h)?HASH_UPDATE:HASH_ADD ZEND_FILE_LINE_CC);
+               _zend_hash_quick_add_or_update(&r->_cache.options, key, keylen, h, zoption, sizeof(zval *), NULL, 
+                       zend_hash_quick_exists(&r->_cache.options, key, keylen, h)?HASH_UPDATE:HASH_ADD ZEND_FILE_LINE_CC);
 #else
 #else
-       zend_hash_add_or_update(&r->_cache.options, key, keylen, zoption, sizeof(zval *), NULL,
-               zend_hash_exists(&r->_cache.options, key, keylen)?HASH_UPDATE:HASH_ADD);
+               zend_hash_add_or_update(&r->_cache.options, key, keylen, zoption, sizeof(zval *), NULL,
+                       zend_hash_exists(&r->_cache.options, key, keylen)?HASH_UPDATE:HASH_ADD);
 #endif
 #endif
+       }
        
        return *zoption;
 }
        
        return *zoption;
 }
index 69306af..73838c6 100644 (file)
@@ -271,6 +271,8 @@ HttpUtil, HttpMessage, HttpRequest, HttpRequestPool; HttpResponse (PHP-5.1)
   />
   <filelist>
    <install as="functions.html" name="docs/functions.html"/>
   />
   <filelist>
    <install as="functions.html" name="docs/functions.html"/>
+   <install as="examples/extract.php" name="docs/examples/extract.php"/>
+   <install as="examples/tutorial.txt" name="docs/examples/tutorial.txt"/>
   </filelist>
  </extsrcrelease>
  <changelog />
   </filelist>
  </extsrcrelease>
  <changelog />