]> granicus.if.org Git - php/commitdiff
Commit these before Sterling renames the files again :-)
authorWez Furlong <wez@php.net>
Thu, 14 Nov 2002 11:41:24 +0000 (11:41 +0000)
committerWez Furlong <wez@php.net>
Thu, 14 Nov 2002 11:41:24 +0000 (11:41 +0000)
When curlstreams are enabled, registers a each supported protocol
with PHP.
"More Correctly" implement eof for curlstreams.
Still not ready for anything like primetime.

ext/curl/interface.c
ext/curl/streams.c

index 38992c7e3b950b7b8da477e72a503a0128f8b847..eeb5fb2f1d9675b4be8b6463173e4e4c585212d6 100644 (file)
@@ -320,10 +320,21 @@ PHP_MINIT_FUNCTION(curl)
        }
 
 #ifdef PHP_CURL_URL_WRAPPERS
+# if HAVE_CURL_VERSION_INFO
+       {
+               curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
+               char **p = (char **)info->protocols;
+
+               while (*p != NULL) {
+                       php_register_url_stream_wrapper(*p++, &php_curl_wrapper TSRMLS_CC);
+               }
+       }
+# else
        php_register_url_stream_wrapper("http", &php_curl_wrapper TSRMLS_CC);
        php_register_url_stream_wrapper("https", &php_curl_wrapper TSRMLS_CC);
        php_register_url_stream_wrapper("ftp", &php_curl_wrapper TSRMLS_CC);
        php_register_url_stream_wrapper("ldap", &php_curl_wrapper TSRMLS_CC);
+# endif
 #endif
        
        return SUCCESS;
index eaee95409dad498059087d18f393a3331d164bbe..d7f613f7cfb5e4416b5ff6c1b445dbaca397136e 100644 (file)
@@ -140,18 +140,6 @@ static size_t php_curl_stream_read(php_stream *stream, char *buf, size_t count T
 {
        php_curl_stream *curlstream = (php_curl_stream*)stream->abstract;
        size_t didread = 0;
-
-       if (buf == NULL && count == 0) {
-               /* check for EOF */
-
-               /* if we have buffered data, then we are not at EOF */
-               if (curlstream->readbuffer.writepos > 0
-                               && curlstream->readbuffer.readpos < curlstream->readbuffer.writepos)
-                       return 0;
-               
-
-               return curlstream->pending ? 0 : EOF;
-       }
        
        if (curlstream->readbuffer.readpos >= curlstream->readbuffer.writepos && curlstream->pending) {
                /* we need to read some more data */
@@ -198,6 +186,11 @@ static size_t php_curl_stream_read(php_stream *stream, char *buf, size_t count T
                curlstream->readbuffer.readpos = php_stream_tell(curlstream->readbuffer.buf);
 
        }
+
+       if (didread == 0) {
+               stream->eof = 1;
+       }
+       
        return didread;
 }