Skip to content

hyper: root cause of curl test 565 failure #8896

@pmk21

Description

@pmk21

I did this

Ran curl test 565, analyzed the debug trace and generated logs, concluded that the first POST request seems to be missing the terminating chunk which has to be inputted during the read callback. This is possibly causing some issues in hyper.

Initial request from server.input -

POST /565 HTTP/1.1
Host: 127.0.0.1:37051
Accept: */*
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded

3
one
3
two
5
three
1D
and a final longer crap: four
0

Requests after fix -

POST /565 HTTP/1.1
Host: 127.0.0.1:42461
Accept: */*
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded

0

POST /565 HTTP/1.1
Host: 127.0.0.1:42461
Authorization: Digest username="foo", realm="testrealm", nonce="1053604144", uri="/565", response="877424f750af047634dbd94f9933217b"
Accept: */*
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

3
one
3
two
5
three
1D
and a final longer crap: four
0

Patched the lib510.c file to allow the test to pass -

diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c
index 2b8da207d..a5bd06a9c 100644
--- a/tests/libtest/lib510.c
+++ b/tests/libtest/lib510.c
@@ -36,6 +36,7 @@ struct WriteThis {
   int counter;
 };
 
+#if defined(USE_HYPER) && defined(LIB565)
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 {
   struct WriteThis *pooh = (struct WriteThis *)userp;
@@ -44,6 +45,11 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
   if(size*nmemb < 1)
     return 0;
 
+  if(pooh->counter == -1) {
+    pooh->counter++;
+    return 0;
+  }
+
   data = post[pooh->counter];
 
   if(data) {
@@ -58,6 +64,30 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
   }
   return 0;                         /* no more data left to deliver */
 }
+#else
+static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+{
+  struct WriteThis *pooh = (struct WriteThis *)userp;
+  const char *data;
+
+  if(size*nmemb < 1)
+    return 0;
+
+  data = post[pooh->counter];
+
+  if(data) {
+    size_t len = strlen(data);
+    if(size*nmemb < len) {
+      fprintf(stderr, "read buffer is too small to run test\n");
+      return 0;
+    }
+    memcpy(ptr, data, len);
+    pooh->counter++; /* advance pointer */
+    return len;
+  }
+  return 0;                         /* no more data left to deliver */
+}
+#endif
 
 int test(char *URL)
 {
@@ -65,7 +95,11 @@ int test(char *URL)
   CURLcode res = CURLE_OK;
   struct curl_slist *slist = NULL;
   struct WriteThis pooh;
+#if defined(USE_HYPER) && defined(LIB565)
+  pooh.counter = -1;
+#else
   pooh.counter = 0;
+#endif
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");

curl/libcurl version

curl 7.83.1-DEV (x86_64-pc-linux-gnu) libcurl/7.83.1-DEV OpenSSL/1.1.1o zlib/1.2.12 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.2 libpsl/0.21.1 (+libidn2/2.3.0) librtmp/2.3 Hyper/0.14.18 OpenLDAP/2.6.1
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli Debug HSTS HTTP2 HTTPS-proxy IDN Largefile libz NTLM NTLM_WB PSL SSL TLS-SRP TrackMemory UnixSockets zstd

operating system

Linux msi 5.15.38-1-MANJARO #1 SMP PREEMPT Mon May 9 07:52:21 UTC 2022 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions