- fix typo
authorMichael Wallner <mike@php.net>
Wed, 13 Sep 2006 12:56:56 +0000 (12:56 +0000)
committerMichael Wallner <mike@php.net>
Wed, 13 Sep 2006 12:56:56 +0000 (12:56 +0000)
- the global datashare should really use the global handle

http.c
http_request_datashare_api.c
http_requestdatashare_object.c
package2.xml
php_http_request_datashare_api.h
tests/HttpRequestDataShare_002.phpt [new file with mode: 0644]

diff --git a/http.c b/http.c
index 51d452a..5a0b058 100644 (file)
--- a/http.c
+++ b/http.c
@@ -241,7 +241,7 @@ PHP_INI_BEGIN()
 #ifdef ZEND_ENGINE_2
        HTTP_PHP_INI_ENTRY("http.request.datashare.cookie", "0", PHP_INI_SYSTEM, OnUpdateBool, request.datashare.cookie)
        HTTP_PHP_INI_ENTRY("http.request.datashare.dns", "0", PHP_INI_SYSTEM, OnUpdateBool, request.datashare.dns)
-       HTTP_PHP_INI_ENTRY("http.request.datashare.sll", "0", PHP_INI_SYSTEM, OnUpdateBool, request.datashare.ssl)
+       HTTP_PHP_INI_ENTRY("http.request.datashare.ssl", "0", PHP_INI_SYSTEM, OnUpdateBool, request.datashare.ssl)
        HTTP_PHP_INI_ENTRY("http.request.datashare.connect", "0", PHP_INI_SYSTEM, OnUpdateBool, request.datashare.connect)
 #endif
 #ifdef HTTP_HAVE_ZLIB
index 4983377..efcdb84 100644 (file)
@@ -32,6 +32,11 @@ static int http_request_datashare_compare_handles(void *h1, void *h2);
 static void http_request_datashare_lock_func(CURL *handle, curl_lock_data data, curl_lock_access locktype, void *userptr);
 static void http_request_datashare_unlock_func(CURL *handle, curl_lock_data data, void *userptr);
 
+http_request_datashare *_http_request_datashare_global_get(void)
+{
+       return &http_request_datashare_global;
+}
+
 PHP_MINIT_FUNCTION(http_request_datashare)
 {
        curl_lock_data val;
index e3872f6..451aefe 100644 (file)
@@ -272,7 +272,7 @@ static inline zval *_http_requestdatashare_instantiate(zval *this_ptr, zend_bool
        if (!this_ptr) {
                MAKE_STD_ZVAL(this_ptr);
                Z_TYPE_P(this_ptr) = IS_OBJECT;
-               this_ptr->value.obj = http_requestdatashare_object_new(http_requestdatashare_object_ce);
+               this_ptr->value.obj = http_requestdatashare_object_new_ex(http_requestdatashare_object_ce, global ? http_request_datashare_global_get() : NULL, NULL);
        }
        if (global) {
                if (HTTP_G->request.datashare.cookie) {
index a5a2935..829948f 100644 (file)
@@ -198,6 +198,7 @@ support. Parallel requests are available for PHP 5 and greater.
     <file role="test" name="HttpRequest_009.phpt"/>
     <file role="test" name="HttpRequest_010.phpt"/>
     <file role="test" name="HttpRequestDataShare_001.phpt"/>
+    <file role="test" name="HttpRequestDataShare_002.phpt"/>
     <file role="test" name="HttpRequestPool_001.phpt"/>
     <file role="test" name="HttpRequestPool_002.phpt"/>
     <file role="test" name="HttpRequestPool_003.phpt"/>
index 179124e..831712f 100644 (file)
@@ -28,6 +28,9 @@ typedef struct _http_request_datashare_t {
        http_request_datashare_lock *locks;
 } http_request_datashare;
 
+#define http_request_datashare_global_get _http_request_datashare_global_get
+extern http_request_datashare *_http_request_datashare_global_get(void);
+
 extern PHP_MINIT_FUNCTION(http_request_datashare);
 extern PHP_MSHUTDOWN_FUNCTION(http_request_datashare);
 
diff --git a/tests/HttpRequestDataShare_002.phpt b/tests/HttpRequestDataShare_002.phpt
new file mode 100644 (file)
index 0000000..0b2f0ac
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+HttpRequestDataShare global
+--SKIPIF--
+<?php
+include "skip.inc";
+checkcls("HttpRequestDataShare");
+?>
+--INI--
+http.request.datashare.cookie = 1
+--FILE--
+<?php
+echo "-TEST\n";
+
+$s = HttpRequestDataShare::singleton(true);
+
+$r1 = new HttpRequest("http://www.google.com/");
+$r2 = new HttpRequest("http://www.google.com/");
+
+$r1->enableCookies();
+$r2->enableCookies();
+
+$s->attach($r1);
+$s->attach($r2);
+
+$r1->send();
+$r2->send();
+
+$s->reset();
+
+var_dump(current($r1->getResponseCookies())->cookies["PREF"] === HttpUtil::parseCookie($r2->getRequestMessage()->getHeader("Cookie"))->cookies["PREF"]);
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+bool(true)
+Done