CURLOPT_BUFFERSIZE allows an application to set a prefered buffer size
authorDaniel Stenberg <daniel@haxx.se>
Sat, 15 Jun 2002 21:00:54 +0000 (21:00 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 15 Jun 2002 21:00:54 +0000 (21:00 +0000)
for receiving data from the network. It is meant as a hint, not as a forced
limit.

lib/transfer.c
lib/url.c
lib/urldata.h

index 893897b05cd04c4f07f6d65a3905bf4b282cd678..d36c90fce7c1d0c7c722e83cb1bc17f559db040d 100644 (file)
@@ -220,7 +220,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
 
       /* read! */
       result = Curl_read(conn, conn->sockfd, k->buf,
-                         BUFSIZE -1, &nread);
+                         data->set.buffer_size?
+                         data->set.buffer_size:BUFSIZE -1,
+                         &nread);
 
       if(0>result)
         break; /* get out of loop */
index 6d0b55ef432921b00e62836e1b87cc236b1f7679..17cd79c9a2eb77e09947a0c1b9886bc4ffdde3ba 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1011,6 +1011,19 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
      */
     data->set.telnet_options = va_arg(param, struct curl_slist *);
     break;
+
+  case CURLOPT_BUFFERSIZE:
+    /*
+     * The application kindly asks for a differently sized receive buffer.
+     * If it seems reasonable, we'll use it.
+     */
+    data->set.buffer_size = va_arg(param, long);
+
+    if(data->set.buffer_size> (BUFSIZE -1 ))
+      data->set.buffer_size = 0; /* huge internal default */
+
+    break;
+
   default:
     /* unknown tag and its companion, just ignore: */
     return CURLE_FAILED_INIT; /* correct this */
index 161cc0004fd8db0669359c416a576ddca224c07d..cb0e3dec9ffde465b1d04f448d614414afeaa944 100644 (file)
@@ -631,6 +631,7 @@ struct UserDefined {
   struct ssl_config_data ssl;  /* user defined SSL stuff */
 
   int dns_cache_timeout; /* DNS cache timeout */
+  long buffer_size;      /* size of receive buffer to use */
   
 /* Here follows boolean settings that define how to behave during
    this session. They are STATIC, set by libcurl users or at least initially