]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: get CURLOPT_REQUEST_TARGET working with a HTTP proxy
authorFabian Keil <fk@fabiankeil.de>
Tue, 19 Jan 2021 10:13:41 +0000 (11:13 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 20 Jan 2021 14:21:13 +0000 (15:21 +0100)
Added test 1613 to verify.

Closes #6490

lib/http.c
tests/data/Makefile.inc
tests/data/test1613 [new file with mode: 0644]

index 83484d3af2dfd1e141b6b657eb31cf9b7a3d1f5c..b0bca64c4167f3a7045d49f6a6dcf38c2af126d4 100644 (file)
@@ -2177,8 +2177,9 @@ CURLcode Curl_http_target(struct Curl_easy *data,
 
     curl_url_cleanup(h);
 
-    /* url */
-    result = Curl_dyn_add(r, url);
+    /* target or url */
+    result = Curl_dyn_add(r, data->set.str[STRING_TARGET]?
+      data->set.str[STRING_TARGET]:url);
     free(url);
     if(result)
       return (result);
index 08ac64882f434ef40357c99cab8426950571a880..f92c50beb6f23cd0ec1e68d97832f36937feba2d 100644 (file)
@@ -192,7 +192,7 @@ test1566 test1567 test1568 \
 test1590 test1591 test1592 test1593 test1594 test1595 test1596 \
 \
 test1600 test1601 test1602 test1603 test1604 test1605 test1606 test1607 \
-test1608 test1609 test1610 test1611 test1612 \
+test1608 test1609 test1610 test1611 test1612 test1613 \
 \
 test1620 test1621 \
 \
diff --git a/tests/data/test1613 b/tests/data/test1613
new file mode 100644 (file)
index 0000000..ae6cab0
--- /dev/null
@@ -0,0 +1,53 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP proxy
+--request-target
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK\r
+Date: Sat, 29 Feb 2020 16:10:44 GMT\r
+Server: Blafasel/1.1\r
+Last-Modified: Sat, 29 Feb 2020 16:10:44 GMT\r
+Content-Length: 0\r
+Connection: close\r
+Content-Type: text/html\r
+\r
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+Send "OPTIONS *" with --request-target to a proxy
+</name>
+<features>
+proxy
+</features>
+<command>
+--request-target '*' -X OPTIONS --proxy http://%HOSTIP:%HTTPPORT/ -H "Testno: 1613" http://www.example.org/
+</command>
+</client>
+
+<verify>
+<protocol>
+OPTIONS * HTTP/1.1\r
+Host: www.example.org\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+Proxy-Connection: Keep-Alive\r
+Testno: 1613\r
+\r
+</protocol>
+</verify>
+</testcase>