curl/tests/data/test1977
Jay Satiro 5ffc73c78e transfer: fix CURLOPT_CURLU override logic
- Change setopt and pretransfer to always reset URL related variables
  for a CURLU handle set CURLOPT_CURLU.

This change is to ensure we are in compliance with the doc which says
CURLU handles must be able to override a URL set via CURLOPT_URL and
that if the contents of the CURLU handle changes between transfers then
the updated contents must be used.

Prior to this change, although subsequent transfers appear to be
performed correctly in those cases, the work URL `data->state.url` was
not updated. CURLINFO_EFFECTIVE_URL returns data->state.url to the user
so it would return the URL from the initial transfer which was the wrong
URL. It's likely there are other cases as well.

Ref: https://curl.se/libcurl/c/CURLOPT_CURLU.html

Reported-by: Nicolás San Martín

Fixes https://github.com/curl/curl/issues/15984
Closes https://github.com/curl/curl/pull/15985
2025-01-14 04:36:13 -05:00

63 lines
1.1 KiB
Plaintext

<testcase>
<info>
<keywords>
CURLOPT_CURLU
CURLINFO_EFFECTIVE_URL
</keywords>
</info>
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Type: text/html
Funny-head: yesyes swsclose
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
CURLOPT_CURLU and CURLINFO_EFFECTIVE_URL
</name>
<tool>
lib%TESTNUMBER
</tool>
# The test does three transfers to check how CURLINFO_EFFECTIVE_URL is reported
# when CURLOPT_CURLU changes between transfers. (Bug #15984)
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<stdout>
effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER
effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER?foo
effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER?foo&bar
</stdout>
<protocol>
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
GET /%TESTNUMBER?foo HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
GET /%TESTNUMBER?foo&bar HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
</protocol>
</verify>
</testcase>