[PHP-CVS] cvs: php-src(PHP_5_3) /ext/curl streams.c /ext/standard http_fopen_wrapper.c

2009-05-04 Thread Jani Taskinen
janiTue May  5 00:31:56 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/curl   streams.c 
/php-src/ext/standard   http_fopen_wrapper.c 
  Log:
  MFH: - Fixed Bug #45092header HTTP context option not being used 
(--with-curlwrappers)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/curl/streams.c?r1=1.14.2.2.2.11.2.4r2=1.14.2.2.2.11.2.5diff_format=u
Index: php-src/ext/curl/streams.c
diff -u php-src/ext/curl/streams.c:1.14.2.2.2.11.2.4 
php-src/ext/curl/streams.c:1.14.2.2.2.11.2.5
--- php-src/ext/curl/streams.c:1.14.2.2.2.11.2.4Mon Feb 23 15:58:19 2009
+++ php-src/ext/curl/streams.c  Tue May  5 00:31:56 2009
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: streams.c,v 1.14.2.2.2.11.2.4 2009/02/23 15:58:19 iliaa Exp $ */
+/* $Id: streams.c,v 1.14.2.2.2.11.2.5 2009/05/05 00:31:56 jani Exp $ */
 
 /* This file implements cURL based wrappers.
  * NOTE: If you are implementing your own streams that are intended to
@@ -48,6 +48,7 @@
 #include ext/standard/php_smart_str.h
 #include ext/standard/info.h
 #include ext/standard/file.h
+#include ext/standard/php_string.h
 #include php_curl.h
 
 static size_t on_data_available(char *data, size_t size, size_t nmemb, void 
*ctx)
@@ -263,6 +264,7 @@
php_stream *stream;
php_curl_stream *curlstream;
zval *tmp, **ctx_opt = NULL;
+   struct curl_slist *slist = NULL;
 
curlstream = emalloc(sizeof(php_curl_stream));
memset(curlstream, 0, sizeof(php_curl_stream));
@@ -311,6 +313,15 @@

/* TODO: read cookies and options from context */
if (context  !strncasecmp(filename, http, sizeof(http)-1)) {
+   /* Protocol version */
+   if (SUCCESS == php_stream_context_get_option(context, http, 
protocol_version, ctx_opt)  Z_TYPE_PP(ctx_opt) == IS_DOUBLE) {
+   if (Z_DVAL_PP(ctx_opt) == 1.1) {
+   curl_easy_setopt(curlstream-curl, 
CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+   } else {
+   curl_easy_setopt(curlstream-curl, 
CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+   }
+   }
+
if (SUCCESS == php_stream_context_get_option(context, http, 
curl_verify_ssl_host, ctx_opt)  Z_TYPE_PP(ctx_opt) == IS_BOOL  
Z_LVAL_PP(ctx_opt) == 1) {
curl_easy_setopt(curlstream-curl, 
CURLOPT_SSL_VERIFYHOST, 1);
} else {
@@ -326,20 +337,34 @@
if (SUCCESS == php_stream_context_get_option(context, http, 
user_agent, ctx_opt)  Z_TYPE_PP(ctx_opt) == IS_STRING) {
curl_easy_setopt(curlstream-curl, CURLOPT_USERAGENT, 
Z_STRVAL_PP(ctx_opt));
}
-   if (SUCCESS == php_stream_context_get_option(context, http, 
header, ctx_opt)  Z_TYPE_PP(ctx_opt) == IS_ARRAY) {
-   HashPosition pos;
-   zval **header = NULL;
-   struct curl_slist *hl = NULL;
+   if (SUCCESS == php_stream_context_get_option(context, http, 
header, ctx_opt)) {
+   if (Z_TYPE_PP(ctx_opt) == IS_ARRAY) {
+   HashPosition pos;
+   zval **header = NULL;

-   for 
(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(ctx_opt), pos);
-   SUCCESS == 
zend_hash_get_current_data_ex(Z_ARRVAL_PP(ctx_opt), (void *)header, pos);
-   zend_hash_move_forward_ex(Z_ARRVAL_PP(ctx_opt), 
pos)) {
-   if (Z_TYPE_PP(header) == IS_STRING) {
-   hl = curl_slist_append(hl, 
Z_STRVAL_PP(header));
+   for 
(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(ctx_opt), pos);
+   SUCCESS == 
zend_hash_get_current_data_ex(Z_ARRVAL_PP(ctx_opt), (void *)header, pos);
+   
zend_hash_move_forward_ex(Z_ARRVAL_PP(ctx_opt), pos)
+   ) {
+   if (Z_TYPE_PP(header) == IS_STRING) {
+   slist = 
curl_slist_append(slist, Z_STRVAL_PP(header));
+   }
}
+   } else if (Z_TYPE_PP(ctx_opt) == IS_STRING  
Z_STRLEN_PP(ctx_opt)) {
+   char *p, *token, *trimmed, *copy_ctx_opt;
+
+   copy_ctx_opt = php_trim(Z_STRVAL_PP(ctx_opt), 
Z_STRLEN_PP(ctx_opt), NULL, 0, NULL, 3 TSRMLS_CC);
+   p = php_strtok_r(copy_ctx_opt, \r\n, token);
+   while (p) {
+   trimmed = php_trim(p, strlen(p), NULL, 
0, NULL, 3 TSRMLS_CC);
+

Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/curl streams.c

2009-02-23 Thread Pierre Joye
hi Ilia,

NEWS? :)

thanks for your work!

On Mon, Feb 23, 2009 at 4:58 PM, Ilia Alshanetsky il...@php.net wrote:
 iliaa           Mon Feb 23 15:58:19 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/curl   streams.c
  Log:

  Fixed bug #47477 (php_curl_stream_read() unnecessarily sleeps 15 secs under
  heavy load)

  # Patch by giuseppe bonacci


 http://cvs.php.net/viewvc.cgi/php-src/ext/curl/streams.c?r1=1.14.2.2.2.11.2.3r2=1.14.2.2.2.11.2.4diff_format=u
 Index: php-src/ext/curl/streams.c
 diff -u php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3 
 php-src/ext/curl/streams.c:1.14.2.2.2.11.2.4
 --- php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3        Wed Dec 31 11:15:35 
 2008
 +++ php-src/ext/curl/streams.c  Mon Feb 23 15:58:19 2009
 @@ -16,7 +16,7 @@
    +--+
  */

 -/* $Id: streams.c,v 1.14.2.2.2.11.2.3 2008/12/31 11:15:35 sebastian Exp $ */
 +/* $Id: streams.c,v 1.14.2.2.2.11.2.4 2009/02/23 15:58:19 iliaa Exp $ */

  /* This file implements cURL based wrappers.
  * NOTE: If you are implementing your own streams that are intended to
 @@ -169,7 +169,8 @@
                        tv.tv_sec = 15; /* TODO: allow this to be configured 
 from the script */

                        /* wait for data */
 -                       switch (select(curlstream-maxfd + 1, 
 curlstream-readfds, curlstream-writefds, curlstream-excfds, tv)) {
 +                       switch ((curlstream-maxfd  0) ? 1 :
 +                                       select(curlstream-maxfd + 1, 
 curlstream-readfds, curlstream-writefds, curlstream-excfds, tv)) {
                                case -1:
                                        /* error */
                                        return 0;
 @@ -182,7 +183,8 @@
                                                curlstream-mcode = 
 curl_multi_perform(curlstream-multi, curlstream-pending);
                                        } while (curlstream-mcode == 
 CURLM_CALL_MULTI_PERFORM);
                        }
 -               } while (curlstream-readbuffer.readpos = 
 curlstream-readbuffer.writepos  curlstream-pending  0);
 +               } while (curlstream-maxfd = 0 
 +                               curlstream-readbuffer.readpos = 
 curlstream-readbuffer.writepos  curlstream-pending  0);

        }




 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/curl streams.c

2009-02-23 Thread Ilia Alshanetsky
I am going to back-port this to 5.2 once 5.2.8 is out, so no point in  
adding it to the 5.3 news file, just to remove it a week later.



On 23-Feb-09, at 11:03 AM, Pierre Joye wrote:


hi Ilia,

NEWS? :)

thanks for your work!

On Mon, Feb 23, 2009 at 4:58 PM, Ilia Alshanetsky il...@php.net  
wrote:

iliaa   Mon Feb 23 15:58:19 2009 UTC

 Modified files:  (Branch: PHP_5_3)
   /php-src/ext/curl   streams.c
 Log:

 Fixed bug #47477 (php_curl_stream_read() unnecessarily sleeps 15  
secs under

 heavy load)

 # Patch by giuseppe bonacci


http://cvs.php.net/viewvc.cgi/php-src/ext/curl/streams.c?r1=1.14.2.2.2.11.2.3r2=1.14.2.2.2.11.2.4diff_format=u
Index: php-src/ext/curl/streams.c
diff -u php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3 php-src/ext/ 
curl/streams.c:1.14.2.2.2.11.2.4
--- php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3Wed Dec 31  
11:15:35 2008

+++ php-src/ext/curl/streams.c  Mon Feb 23 15:58:19 2009
@@ -16,7 +16,7 @@

+ 
--+

 */

-/* $Id: streams.c,v 1.14.2.2.2.11.2.3 2008/12/31 11:15:35  
sebastian Exp $ */
+/* $Id: streams.c,v 1.14.2.2.2.11.2.4 2009/02/23 15:58:19 iliaa  
Exp $ */


 /* This file implements cURL based wrappers.
 * NOTE: If you are implementing your own streams that are intended  
to

@@ -169,7 +169,8 @@
   tv.tv_sec = 15; /* TODO: allow this to be  
configured from the script */


   /* wait for data */
-   switch (select(curlstream-maxfd + 1,  
curlstream-readfds, curlstream-writefds, curlstream-excfds,  
tv)) {

+   switch ((curlstream-maxfd  0) ? 1 :
+   select(curlstream-maxfd +  
1, curlstream-readfds, curlstream-writefds, curlstream- 
excfds, tv)) {

   case -1:
   /* error */
   return 0;
@@ -182,7 +183,8 @@
   curlstream-mcode =  
curl_multi_perform(curlstream-multi, curlstream-pending);
   } while (curlstream-mcode  
== CURLM_CALL_MULTI_PERFORM);

   }
-   } while (curlstream-readbuffer.readpos =  
curlstream-readbuffer.writepos  curlstream-pending  0);

+   } while (curlstream-maxfd = 0 
+   curlstream-readbuffer.readpos =  
curlstream-readbuffer.writepos  curlstream-pending  0);


   }




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
Pierre

http://blog.thepimp.net | http://www.libgd.org


Ilia Alshanetsky





--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/curl streams.c

2009-02-23 Thread Pierre Joye
ah ok, even better then :)

On Mon, Feb 23, 2009 at 5:10 PM, Ilia Alshanetsky i...@prohost.org wrote:
 I am going to back-port this to 5.2 once 5.2.8 is out, so no point in adding
 it to the 5.3 news file, just to remove it a week later.


 On 23-Feb-09, at 11:03 AM, Pierre Joye wrote:

 hi Ilia,

 NEWS? :)

 thanks for your work!

 On Mon, Feb 23, 2009 at 4:58 PM, Ilia Alshanetsky il...@php.net wrote:

 iliaa           Mon Feb 23 15:58:19 2009 UTC

  Modified files:              (Branch: PHP_5_3)
   /php-src/ext/curl   streams.c
  Log:

  Fixed bug #47477 (php_curl_stream_read() unnecessarily sleeps 15 secs
 under
  heavy load)

  # Patch by giuseppe bonacci



 http://cvs.php.net/viewvc.cgi/php-src/ext/curl/streams.c?r1=1.14.2.2.2.11.2.3r2=1.14.2.2.2.11.2.4diff_format=u
 Index: php-src/ext/curl/streams.c
 diff -u php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3
 php-src/ext/curl/streams.c:1.14.2.2.2.11.2.4
 --- php-src/ext/curl/streams.c:1.14.2.2.2.11.2.3        Wed Dec 31
 11:15:35 2008
 +++ php-src/ext/curl/streams.c  Mon Feb 23 15:58:19 2009
 @@ -16,7 +16,7 @@

 +--+
  */

 -/* $Id: streams.c,v 1.14.2.2.2.11.2.3 2008/12/31 11:15:35 sebastian Exp
 $ */
 +/* $Id: streams.c,v 1.14.2.2.2.11.2.4 2009/02/23 15:58:19 iliaa Exp $ */

  /* This file implements cURL based wrappers.
  * NOTE: If you are implementing your own streams that are intended to
 @@ -169,7 +169,8 @@
                       tv.tv_sec = 15; /* TODO: allow this to be
 configured from the script */

                       /* wait for data */
 -                       switch (select(curlstream-maxfd + 1,
 curlstream-readfds, curlstream-writefds, curlstream-excfds, tv)) {
 +                       switch ((curlstream-maxfd  0) ? 1 :
 +                                       select(curlstream-maxfd + 1,
 curlstream-readfds, curlstream-writefds, curlstream-excfds, tv)) {
                               case -1:
                                       /* error */
                                       return 0;
 @@ -182,7 +183,8 @@
                                               curlstream-mcode =
 curl_multi_perform(curlstream-multi, curlstream-pending);
                                       } while (curlstream-mcode ==
 CURLM_CALL_MULTI_PERFORM);
                       }
 -               } while (curlstream-readbuffer.readpos =
 curlstream-readbuffer.writepos  curlstream-pending  0);
 +               } while (curlstream-maxfd = 0 
 +                               curlstream-readbuffer.readpos =
 curlstream-readbuffer.writepos  curlstream-pending  0);

       }




 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 Pierre

 http://blog.thepimp.net | http://www.libgd.org

 Ilia Alshanetsky








-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php