diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
index b80ffb618e..2d2b87a864 100644
--- a/tests/data/Makefile.inc
+++ b/tests/data/Makefile.inc
@@ -201,7 +201,7 @@ test1558 test1559 test1560 test1561 test1562 test1563 test1564 test1565 \
test1566 test1567 test1568 test1569 test1570 \
\
test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
-\
+test1598 \
test1600 test1601 test1602 test1603 test1604 test1605 test1606 test1607 \
test1608 test1609 test1610 test1611 test1612 test1613 test1614 test1615 \
\
diff --git a/tests/data/test1598 b/tests/data/test1598
new file mode 100644
index 0000000000..eb0ade1040
--- /dev/null
+++ b/tests/data/test1598
@@ -0,0 +1,59 @@
+
+
+
+HTTP
+HTTP POST
+CURLOPT_HTTPTRAILER_FUNCTION
+CURLOPT_HTTPTRAILER_DATA
+
+
+
+# Server-side
+
+
+HTTP/1.0 200 OK swsclose
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+
+
+# Client-side
+
+
+http
+
+
+http
+
+
+HTTP POST with trailers at the end
+
+
+lib%TESTNUMBER
+
+
+http://%HOSTIP:%HTTPPORT/bzz/%TESTNUMBER
+
+
+more than one byte
+
+
+
+# Verify data after the test has been "shot"
+
+
+POST /bzz/%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Trailer: my-super-awesome-trailer, my-other-awesome-trailer
+Transfer-Encoding: chunked
+Content-Type: application/x-www-form-urlencoded
+
+11
+xxx=yyy&aaa=bbbbb
+0
+my-super-awesome-trailer: trail1
+my-other-awesome-trailer: trail2
+
+
+
+
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 1a61deb623..32cc180b02 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -62,7 +62,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect libprereq \
lib1540 lib1542 lib1543 lib1545 \
lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 \
- lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 \
+ lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 lib1598 \
\
lib1662 \
\
@@ -534,6 +534,9 @@ lib1596_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1596
lib1597_SOURCES = lib1597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1597_LDADD = $(TESTUTIL_LIBS)
+lib1598_SOURCES = lib1598.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib1598_LDADD = $(TESTUTIL_LIBS)
+
lib1662_SOURCES = lib1662.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1662_LDADD = $(TESTUTIL_LIBS)
diff --git a/tests/libtest/lib1598.c b/tests/libtest/lib1598.c
new file mode 100644
index 0000000000..63cdfcfb64
--- /dev/null
+++ b/tests/libtest/lib1598.c
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, , et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+
+/*
+ * This unit test PUT http data over proxy. Proxy header will be different
+ * from server http header
+ */
+
+#include "test.h"
+#include
+#include "memdebug.h"
+
+/*
+ * carefully not leak memory on OOM
+ */
+static int trailers_callback(struct curl_slist **list, void *userdata)
+{
+ struct curl_slist *nlist = NULL;
+ struct curl_slist *nlist2 = NULL;
+ (void)userdata;
+ nlist = curl_slist_append(*list, "my-super-awesome-trailer: trail1");
+ if(nlist)
+ nlist2 = curl_slist_append(nlist, "my-other-awesome-trailer: trail2");
+ if(nlist2) {
+ *list = nlist2;
+ return CURL_TRAILERFUNC_OK;
+ }
+ else {
+ curl_slist_free_all(nlist);
+ return CURL_TRAILERFUNC_ABORT;
+ }
+}
+
+static const char *post_data = "xxx=yyy&aaa=bbbbb";
+
+int test(char *URL)
+{
+ CURL *curl = NULL;
+ CURLcode res = CURLE_FAILED_INIT;
+ /* http and proxy header list */
+ struct curl_slist *hhl = NULL, *list;
+
+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+
+ curl = curl_easy_init();
+ if(!curl) {
+ fprintf(stderr, "curl_easy_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ hhl = curl_slist_append(hhl, "Trailer: my-super-awesome-trailer,"
+ " my-other-awesome-trailer");
+ if(!hhl)
+ goto test_cleanup;
+ if(hhl) {
+ list = curl_slist_append(hhl, "Transfer-Encoding: chunked");
+ if(!list)
+ goto test_cleanup;
+ hhl = list;
+ }
+
+ test_setopt(curl, CURLOPT_URL, URL);
+ test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
+ test_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(post_data));
+ test_setopt(curl, CURLOPT_POSTFIELDS, post_data);
+ test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback);
+ test_setopt(curl, CURLOPT_TRAILERDATA, NULL);
+ test_setopt(curl, CURLOPT_VERBOSE, 1L);
+
+ res = curl_easy_perform(curl);
+
+test_cleanup:
+
+ curl_easy_cleanup(curl);
+
+ curl_slist_free_all(hhl);
+
+ curl_global_cleanup();
+
+ return (int)res;
+}