Skip to content

Instantly share code, notes, and snippets.

@kunalekawde
Created May 29, 2020 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunalekawde/8a1ff6ecb1518f50b9834ebe03eef8c2 to your computer and use it in GitHub Desktop.
Save kunalekawde/8a1ff6ecb1518f50b9834ebe03eef8c2 to your computer and use it in GitHub Desktop.
multiplex 1.1 with 2.0 requests, 1.1 request is sent on 2.0 connection
diff --git a/docs/examples/http2-download.c b/docs/examples/http2-download.c
index 333b7df2c..273eaacee 100644
--- a/docs/examples/http2-download.c
+++ b/docs/examples/http2-download.c
@@ -47,7 +47,7 @@ struct transfer {
FILE *out;
};
-#define NUM_HANDLES 1000
+#define NUM_HANDLES 10008
static
void dump(const char *text, int num, unsigned char *ptr, size_t size,
@@ -154,19 +154,29 @@ static void setup(struct transfer *t, int num)
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, t->out);
/* set the same URL */
- curl_easy_setopt(hnd, CURLOPT_URL, "https://localhost:8443/index.html");
+ // curl_easy_setopt(hnd, CURLOPT_URL, "https://localhost:8443/index.html");
+ curl_easy_setopt(hnd, CURLOPT_URL, "http://127.0.0.1:9099/hello2");
+ // POST
+ static const char *postthis = "moo mooo moo moo ahmoo";
+ curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, postthis);
+ curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE, (long)strlen(postthis));
/* please be verbose */
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(hnd, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(hnd, CURLOPT_DEBUGDATA, t);
/* HTTP/2 please */
- curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
+ //curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
+ int cnt = num +1;
+ if ((cnt % 10) == 0)
+ curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+ else
+ curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
/* we use a self-signed test server, skip verification during debugging */
- curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L);
- curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0L);
+ //curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L);
+ //curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 0L);
#if (CURLPIPE_MULTIPLEX > 0)
/* wait for pipe connection to confirm */
@@ -195,6 +205,9 @@ int main(int argc, char **argv)
/* init a multi stack */
multi_handle = curl_multi_init();
+ curl_multi_setopt(multi_handle, CURLMOPT_MAX_HOST_CONNECTIONS, 500);
+ curl_multi_setopt(multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, 1024);
+ curl_multi_setopt(multi_handle, CURLMOPT_MAX_CONCURRENT_STREAMS, 50);
for(i = 0; i < num_transfers; i++) {
setup(&trans[i], i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment