test1509: verify proxy header response headers count

Modified sws to support and use custom CONNECT responses instead of the
previously naive hard-coded version. Made the HTTP test server able to
extract test case number from the host name in a CONNECT request by
finding the number after the last dot. It makes 'machine.moo.123' use
test case 123.

Adapted a larger amount of tests to the new <connect> style.

Bug: http://curl.haxx.se/bug/view.cgi?id=1204
Reported by: Martin Jansen
This commit is contained in:
Daniel Stenberg 2013-03-15 17:28:32 +01:00
parent 142755fa5c
commit 1e29d275c6
30 changed files with 495 additions and 263 deletions

View File

@ -75,6 +75,11 @@ to complete a transfer. The response to each request is found in its own data
section. Validating the entire negotiation sequence can be done by
specifying a datacheck section.
</dataNUM>
<connect>
The connect section is used instead of the 'data' for all CONNECT
requests. The remainder of the rules for the data section then apply but with
a connect prefix.
</connect>
<datacheck [nonewline="yes"]>
if the data is sent but this is what should be checked afterwards. If
'nonewline' is set, we will cut off the trailing newline of this given data
@ -247,13 +252,10 @@ that is returned. The last slash in the URL must be followed by a number. That
number (N) will be used by the test-server to load test case N and return the
data that is defined within the <reply><data></data></reply> section.
If a CONNECT is used to the server (to emulate HTTPS etc over proxy), the port
number given in the CONNECT request will be used to identify which test that
is being run, if the proxy host name is said to start with 'test'.
If there's no non-zero test number found in the above two places, the HTTP test
server will use the number following the last dot in the given url so that
"foo.bar.123" gets treated as test case 123.
If there's no test number found above, the HTTP test server will use the
number following the last dot in the given hostname (made so that a CONNECT
can still pass on test number) so that "foo.bar.123" gets treated as test case
123.
Set type="perl" to write the test case as a perl script. It implies that
there's no memory debugging and valgrind gets shut off for this test.

View File

@ -109,7 +109,7 @@ test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
test1408 test1409 test1410 test1411 test1412 test1413 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 \
test1508 test1509 \
\
test1900 test1901 test1902 test1903 \
\

View File

@ -16,7 +16,7 @@ connection-monitor
</servercmd>
# this is returned first since we get no proxy-auth
<data1001>
<connect1001>
HTTP/1.1 407 Authorization Required to proxy me my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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0
</data1001>
</connect1001>
# This is supposed to be returned when the server gets the second
# Authorization: NTLM line passed-in from the client
<data1002>
<connect1002>
HTTP/1.1 200 Things are fine in proxy land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
</data1002>
</connect1002>
# this is returned when we get a GET!
<data2>
@ -96,7 +96,7 @@ CURL_GETHOSTNAME=curlhost
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://test.remote.example.com:1008/path/10080002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
http://test.remote.example.com.1008:%HTTPPORT/path/10080002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
</command>
<precheck>
chkhostname curlhost
@ -109,19 +109,19 @@ chkhostname curlhost
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.example.com:1008 HTTP/1.1
Host: test.remote.example.com:1008
CONNECT test.remote.example.com.1008:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.1008:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:1008 HTTP/1.1
Host: test.remote.example.com:1008
CONNECT test.remote.example.com.1008:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.1008:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=
Proxy-Connection: Keep-Alive
GET /path/10080002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.example.com:1008
Host: test.remote.example.com.1008:%HTTPPORT
Accept: */*
[DISCONNECT]

View File

@ -12,32 +12,32 @@ HTTP proxy NTLM auth
# Server-side
<reply>
<data>
<connect>
HTTP/1.1 407 Authorization Required to proxy me my dear swsclose
Proxy-Authenticate: NTLM
Content-Length: 21
Connection: close
data to discard
</data>
</connect>
# this is returned first since we get no proxy-auth
<data1001>
<connect1001>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
Content-Length: 28
And you should ignore this data.
</data1001>
</connect1001>
# This is supposed to be returned when the server gets the second
# Authorization: NTLM line passed-in from the client
<data1002>
<connect1002>
HTTP/1.1 200 Things are fine in proxy land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
</data1002>
</connect1002>
# this is returned when we get a GET!
<data2>
@ -102,7 +102,7 @@ CURL_GETHOSTNAME=curlhost
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://test.remote.example.com:1021/path/10210002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth --proxytunnel
http://test.remote.example.com.1021:%HTTPPORT/path/10210002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-anyauth --proxytunnel
</command>
<precheck>
chkhostname curlhost
@ -115,23 +115,23 @@ chkhostname curlhost
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.example.com:1021 HTTP/1.1
Host: test.remote.example.com:1021
CONNECT test.remote.example.com.1021:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.1021:%HTTPPORT
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:1021 HTTP/1.1
Host: test.remote.example.com:1021
CONNECT test.remote.example.com.1021:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.1021:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:1021 HTTP/1.1
Host: test.remote.example.com:1021
CONNECT test.remote.example.com.1021:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.1021:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=
Proxy-Connection: Keep-Alive
GET /path/10210002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.example.com:1021
Host: test.remote.example.com.1021:%HTTPPORT
Accept: */*
</protocol>

View File

@ -12,13 +12,13 @@ FAILURE
#
# Server-side
<reply>
<data>
<connect>
HTTP/1.1 501 Method not implemented swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT
Connection: close
Content-Length: 0
</data>
</connect>
</reply>
#

View File

@ -14,7 +14,7 @@ HTTP proxy Digest auth
<reply>
# this is returned first since we get no proxy-auth
<data>
<connect>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Content-Length: 40000
@ -820,7 +820,7 @@ And you should ignore this data. aaaaaaaaaaaaaaaa
And you should ignore this data. aaaaaaaaaaaaaaaa
And you should ignore this data. aaaaaaaaaaaaaaaa
end of 1 KB aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</data>
</connect>
# this is returned when we get a GET!
<data2>
@ -835,12 +835,12 @@ daniel
</data2>
# then this is returned when we get proxy-auth
<data1000>
<connect1000>
HTTP/1.1 200 OK swsbounce
Server: no
Nice proxy auth sir!
</data1000>
</connect1000>
<datacheck>
HTTP/1.1 407 Authorization Required to proxy me my dear
@ -874,7 +874,7 @@ crypto
HTTP proxy CONNECT auth Digest, large headers and data
</name>
<command>
http://test.remote.haxx.se:1060/path/10600002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
http://test.remote.haxx.se.1060:%HTTPPORT/path/10600002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
</command>
</client>
@ -884,17 +884,17 @@ http://test.remote.haxx.se:1060/path/10600002 --proxy http://%HOSTIP:%HTTPPORT -
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.haxx.se:1060 HTTP/1.1
Host: test.remote.haxx.se:1060
CONNECT test.remote.haxx.se.1060:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.1060:%HTTPPORT
Proxy-Connection: Keep-Alive
CONNECT test.remote.haxx.se:1060 HTTP/1.1
Host: test.remote.haxx.se:1060
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se:1060", response="79e394ffcd42b6c771c7582da1fc4498"
CONNECT test.remote.haxx.se.1060:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.1060:%HTTPPORT
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se.1060:%HTTPPORT", response="e1fbed39c26f4efe284adc0e576ff638"
Proxy-Connection: Keep-Alive
GET /path/10600002 HTTP/1.1
Host: test.remote.haxx.se:1060
Host: test.remote.haxx.se.1060:%HTTPPORT
Accept: */*
</protocol>

View File

@ -15,7 +15,7 @@ HTTP proxy Digest auth
<reply>
# this is returned first since we get no proxy-auth
<data>
<connect>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Transfer-Encoding: chunked
@ -825,7 +825,7 @@ end of 1 KB aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
0
</data>
</connect>
# this is returned when we get a GET!
<data2>
@ -840,12 +840,12 @@ daniel
</data2>
# then this is returned when we get proxy-auth
<data1000>
<connect1000>
HTTP/1.1 200 OK swsbounce
Server: no
Nice proxy auth sir!
</data1000>
</connect1000>
<datacheck>
HTTP/1.1 407 Authorization Required to proxy me my dear
@ -879,7 +879,7 @@ crypto
HTTP proxy CONNECT auth Digest, large headers and chunked data
</name>
<command>
http://test.remote.haxx.se:1061/path/10610002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
http://test.remote.haxx.se.1061:%HTTPPORT/path/10610002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
</command>
</client>
@ -889,17 +889,17 @@ http://test.remote.haxx.se:1061/path/10610002 --proxy http://%HOSTIP:%HTTPPORT -
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.haxx.se:1061 HTTP/1.1
Host: test.remote.haxx.se:1061
CONNECT test.remote.haxx.se.1061:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.1061:%HTTPPORT
Proxy-Connection: Keep-Alive
CONNECT test.remote.haxx.se:1061 HTTP/1.1
Host: test.remote.haxx.se:1061
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se:1061", response="8e96acf6a6214012183879e28e73b2d3"
CONNECT test.remote.haxx.se.1061:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.1061:%HTTPPORT
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se.1061:%HTTPPORT", response="4e23449fa93224834299e7282a70472c"
Proxy-Connection: Keep-Alive
GET /path/10610002 HTTP/1.1
Host: test.remote.haxx.se:1061
Host: test.remote.haxx.se.1061:%HTTPPORT
Accept: */*
</protocol>

View File

@ -13,6 +13,12 @@ proxytunnel
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 Mighty fine indeed
Server: test tunnel 2000
</connect>
<data nocheck="yes">
HTTP/1.0 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
@ -37,7 +43,7 @@ http-proxy
HTTP 1.0 CONNECT with proxytunnel and downgrade GET to HTTP/1.0
</name>
<command>
--proxy1.0 %HOSTIP:%PROXYPORT -p http://%HOSTIP:%HTTPPORT/we/want/that/page/1078 http://%HOSTIP:%HTTPPORT/we/want/that/page/1078
--proxy1.0 %HOSTIP:%PROXYPORT -p http://%HOSTIP.1078:%HTTPPORT/we/want/that/page/1078 http://%HOSTIP.1078:%HTTPPORT/we/want/that/page/1078
</command>
</client>
@ -48,23 +54,24 @@ HTTP 1.0 CONNECT with proxytunnel and downgrade GET to HTTP/1.0
^User-Agent:.*
</strip>
<proxy>
CONNECT %HOSTIP:%HTTPPORT HTTP/1.0
Host: %HOSTIP:%HTTPPORT
CONNECT %HOSTIP.1078:%HTTPPORT HTTP/1.0
Host: %HOSTIP.1078:%HTTPPORT
Proxy-Connection: Keep-Alive
</proxy>
<protocol>
GET /we/want/that/page/1078 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Host: %HOSTIP.1078:%HTTPPORT
Accept: */*
GET /we/want/that/page/1078 HTTP/1.0
Host: %HOSTIP:%HTTPPORT
Host: %HOSTIP.1078:%HTTPPORT
Accept: */*
</protocol>
<stdout>
HTTP/1.1 200 Mighty fine indeed
Server: test tunnel 2000
HTTP/1.0 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT

View File

@ -18,13 +18,15 @@ Content-Length: 27
This is all fine and dandy
</data>
<data1001>
<connect1001>
HTTP/1.1 200 We are fine and cool
Server: Apache/1.3.27 (Dorw1n) PHP/44.1.2
Content-Length: 27
This is all fine and dandy
</data1001>
</connect1001>
<datacheck>
HTTP/1.1 200 We are fine and cool
Server: Apache/1.3.27 (Dorw1n) PHP/44.1.2
@ -50,7 +52,7 @@ NTLM
HTTP POST using CONNECT with --proxy-ntlm but no auth is required
</name>
<command>
http://test.a.galaxy.far.far.away:1097/1097 --proxy http://%HOSTIP:%HTTPPORT --proxy-user foo:bar --proxy-ntlm -d "dummy=value" -p
http://test.a.galaxy.far.far.away.1097:%HTTPPORT/1097 --proxy http://%HOSTIP:%HTTPPORT --proxy-user foo:bar --proxy-ntlm -d "dummy=value" -p
</command>
</client>
@ -60,15 +62,15 @@ http://test.a.galaxy.far.far.away:1097/1097 --proxy http://%HOSTIP:%HTTPPORT --p
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.a.galaxy.far.far.away:1097 HTTP/1.1
Host: test.a.galaxy.far.far.away:1097
CONNECT test.a.galaxy.far.far.away.1097:%HTTPPORT HTTP/1.1
Host: test.a.galaxy.far.far.away.1097:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
User-Agent: curl/7.19.5-CVS (i686-pc-linux-gnu) libcurl/7.19.5-CVS OpenSSL/0.9.8g zlib/1.2.3.3 c-ares/1.6.1-CVS libidn/1.12 libssh2/1.0.1_CVS
Proxy-Connection: Keep-Alive
POST /1097 HTTP/1.1
User-Agent: curl/7.19.5-CVS (i686-pc-linux-gnu) libcurl/7.19.5-CVS OpenSSL/0.9.8g zlib/1.2.3.3 c-ares/1.6.1-CVS libidn/1.12 libssh2/1.0.1_CVS
Host: test.a.galaxy.far.far.away:1097
Host: test.a.galaxy.far.far.away.1097:%HTTPPORT
Accept: */*
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

View File

@ -12,12 +12,21 @@ HTTP proxy
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 Mighty fine indeed
Magic: sure you can FTP me
</connect>
# When doing LIST, we get the default list output hard-coded in the test
# FTP server
<datacheck>
HTTP/1.1 200 Mighty fine indeed
Magic: sure you can FTP me
HTTP/1.1 200 Mighty fine indeed
Magic: sure you can FTP me
total 20
drwxr-xr-x 8 98 98 512 Oct 22 13:06 .
@ -36,6 +45,11 @@ dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr
#
# Client-side
<client>
# please send the real CONNECT connect off to the FTP server's port
<connectport>
%FTPPORT
</connectport>
<server>
ftp
http-proxy
@ -44,7 +58,7 @@ http-proxy
FTP LIST tunneled through HTTP proxy
</name>
<command>
ftp://%HOSTIP:%FTPPORT/ -p -x %HOSTIP:%PROXYPORT
ftp://ftp.1316:%FTPPORT/ -p -x %HOSTIP:%PROXYPORT
</command>
</client>

View File

@ -11,6 +11,13 @@ HTTP proxy
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 Mighty fine indeed
pop3: sure hit me
</connect>
# When doing LIST, we get the default list output hard-coded in the test
# FTP server
<data>
@ -25,6 +32,7 @@ body
<datacheck>
HTTP/1.1 200 Mighty fine indeed
pop3: sure hit me
From: me@somewhere
To: fake@nowhere
@ -47,7 +55,7 @@ http-proxy
POP3 fetch tunneled through HTTP proxy
</name>
<command>
pop3://%HOSTIP:%POP3PORT/1319 -p -x %HOSTIP:%PROXYPORT -u user:secret
pop3://pop.1319:%POP3PORT/1319 -p -x %HOSTIP:%PROXYPORT -u user:secret
</command>
</client>
@ -65,8 +73,8 @@ RETR 1319
QUIT
</protocol>
<proxy>
CONNECT %HOSTIP:%POP3PORT HTTP/1.1
Host: %HOSTIP:%POP3PORT
CONNECT pop.1319:%POP3PORT HTTP/1.1
Host: pop.1319:%POP3PORT
User-Agent: curl/7.24.0-DEV (i686-pc-linux-gnu) libcurl/7.24.0-DEV OpenSSL/1.0.0e zlib/1.2.3.4 c-ares/1.7.6-DEV libidn/1.23 libssh2/1.4.0_DEV librtmp/2.2e
Proxy-Connection: Keep-Alive

View File

@ -11,6 +11,11 @@ HTTP proxy
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 Mighty fine indeed
smtp: sure hit me
</connect>
</reply>
#
@ -30,7 +35,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 1320@foo --mail-rcpt 1320@foobar.example --mail-from 1320@from -T - -p -x %HOSTIP:%PROXYPORT
smtp://smtp.1320:%SMTPPORT/user --mail-rcpt 1320@foo --mail-rcpt 1320@foobar.example --mail-from 1320@from -T - -p -x %HOSTIP:%PROXYPORT
</command>
</client>
@ -57,8 +62,8 @@ body
.
</upload>
<proxy>
CONNECT %HOSTIP:%SMTPPORT HTTP/1.1
Host: %HOSTIP:%SMTPPORT
CONNECT smtp.1320:%SMTPPORT HTTP/1.1
Host: smtp.1320:%SMTPPORT
User-Agent: curl/7.24.0-DEV (i686-pc-linux-gnu) libcurl/7.24.0-DEV OpenSSL/1.0.0e zlib/1.2.3.4 c-ares/1.7.6-DEV libidn/1.23 libssh2/1.4.0_DEV librtmp/2.2e
Proxy-Connection: Keep-Alive

View File

@ -12,6 +12,11 @@ HTTP proxy
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 Mighty fine indeed
imap: sure hit me
</connect>
<data>
From: me@somewhere
To: fake@nowhere
@ -23,6 +28,7 @@ body
</data>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
imap: sure hit me
From: me@somewhere
To: fake@nowhere
@ -45,7 +51,7 @@ http-proxy
IMAP FETCH tunneled through HTTP proxy
</name>
<command>
'imap://%HOSTIP:%IMAPPORT/1321/;UID=1' -u user:secret -p -x %HOSTIP:%PROXYPORT
'imap://imap.1321:%IMAPPORT/1321/;UID=1' -u user:secret -p -x %HOSTIP:%PROXYPORT
</command>
</client>
@ -63,8 +69,8 @@ A004 FETCH 1 BODY[]
A005 LOGOUT
</protocol>
<proxy>
CONNECT %HOSTIP:%IMAPPORT HTTP/1.1
Host: %HOSTIP:%IMAPPORT
CONNECT imap.1321:%IMAPPORT HTTP/1.1
Host: imap.1321:%IMAPPORT
User-Agent: curl/7.24.0-DEV (i686-pc-linux-gnu) libcurl/7.24.0-DEV OpenSSL/1.0.0e zlib/1.2.3.4 c-ares/1.7.6-DEV libidn/1.23 libssh2/1.4.0_DEV librtmp/2.2e
Proxy-Connection: Keep-Alive

88
tests/data/test1509 Normal file
View File

@ -0,0 +1,88 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
HTTP CONNECT
HTTP proxy
proxytunnel
</keywords>
</info>
# Server-side
<reply>
<servercmd>
connection-monitor
</servercmd>
<connect>
HTTP/1.1 200 Mighty fine indeed
Server: the beast that eats naughty clients
</connect>
<data>
HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
</data>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
Server: the beast that eats naughty clients
HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
header length is ........: 239
header length should be..: 239
</datacheck>
</reply>
# Client-side
<client>
<server>
http
http-proxy
</server>
# tool is what to use instead of 'curl'
<tool>
lib1509
</tool>
<name>
simple multi http:// through proxytunnel with authentication info
</name>
<command>
http://the.old.moo.1509:%HTTPPORT/1509 %HOSTIP:%PROXYPORT
</command>
<file name="log/test1509.txt">
foo
bar
bar
foo
moo
</file>
</client>
# Verify data after the test has been "shot"
<verify>
<proxy>
CONNECT the.old.moo.1509:%HTTPPORT HTTP/1.1
Host: the.old.moo.1509:%HTTPPORT
Proxy-Connection: Keep-Alive
</proxy>
<protocol>
GET /1509 HTTP/1.1
Host: the.old.moo.1509:%HTTPPORT
Accept: */*
[DISCONNECT]
</protocol>
</verify>
</testcase>

View File

@ -14,16 +14,18 @@ HTTP proxy Digest auth
<reply>
<servercmd>
connection-monitor
auth_required
</servercmd>
# this is returned first since we get no proxy-auth
<data>
<connect>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
Content-Length: 33
And you should ignore this data.
</data>
</connect>
# this is returned when we get a GET!
<data2>
@ -38,11 +40,11 @@ daniel
</data2>
# then this is returned when we get proxy-auth
<data1000>
<connect1000>
HTTP/1.1 200 OK swsbounce
Server: no
</data1000>
</connect1000>
<datacheck>
HTTP/1.1 407 Authorization Required to proxy me my dear
@ -75,7 +77,7 @@ crypto
HTTP proxy CONNECT auth Digest
</name>
<command>
http://test.remote.haxx.se:206/path/2060002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
http://test.remote.haxx.se.206:%HTTPPORT/path/2060002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-digest --proxytunnel
</command>
</client>
@ -85,18 +87,18 @@ http://test.remote.haxx.se:206/path/2060002 --proxy http://%HOSTIP:%HTTPPORT --p
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.haxx.se:206 HTTP/1.1
Host: test.remote.haxx.se:206
CONNECT test.remote.haxx.se.206:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.206:%HTTPPORT
Proxy-Connection: Keep-Alive
CONNECT test.remote.haxx.se:206 HTTP/1.1
Host: test.remote.haxx.se:206
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se:206", response="676e0836f3e1c5b31bf29770ef9d8224"
CONNECT test.remote.haxx.se.206:%HTTPPORT HTTP/1.1
Host: test.remote.haxx.se.206:%HTTPPORT
Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="test.remote.haxx.se.206:%HTTPPORT", response="003e36decb4dbf6366b3ecb9b87c24ec"
Proxy-Connection: Keep-Alive
GET /path/2060002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.haxx.se:206
Host: test.remote.haxx.se.206:%HTTPPORT
Accept: */*
[DISCONNECT]

View File

@ -13,21 +13,21 @@ HTTP proxy NTLM auth
<reply>
# this is returned first since we get no proxy-auth
<data1001>
<connect1001>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
And you should ignore this data.
</data1001>
</connect1001>
# This is supposed to be returned when the server gets the second
# Authorization: NTLM line passed-in from the client
<data1002>
<connect1002>
HTTP/1.1 200 Things are fine in proxy land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
</data1002>
</connect1002>
# this is returned when we get a GET!
<data2>
@ -86,7 +86,7 @@ CURL_GETHOSTNAME=curlhost
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://test.remote.example.com:209/path/2090002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
http://test.remote.example.com.209:%HTTPPORT/path/2090002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel
</command>
<precheck>
chkhostname curlhost
@ -99,19 +99,19 @@ chkhostname curlhost
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.example.com:209 HTTP/1.1
Host: test.remote.example.com:209
CONNECT test.remote.example.com.209:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.209:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:209 HTTP/1.1
Host: test.remote.example.com:209
CONNECT test.remote.example.com.209:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.209:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=
Proxy-Connection: Keep-Alive
GET /path/2090002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.example.com:209
Host: test.remote.example.com.209:%HTTPPORT
Accept: */*
</protocol>

View File

@ -13,21 +13,21 @@ HTTP proxy NTLM auth
<reply>
# this is returned first since we get no proxy-auth
<data1001>
<connect1001>
HTTP/1.1 407 Authorization Required to proxy me my dear
Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
And you should ignore this data.
</data1001>
</connect1001>
# This is supposed to be returned when the server gets the second
# Authorization: NTLM line passed-in from the client
<data1002>
<connect1002>
HTTP/1.1 200 Things are fine in proxy land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
</data1002>
</connect1002>
# this is returned when we get a GET!
<data2>
@ -86,7 +86,7 @@ CURL_GETHOSTNAME=curlhost
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://test.remote.example.com:213/path/2130002 --proxy1.0 http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
http://test.remote.example.com.213:%HTTPPORT/path/2130002 --proxy1.0 http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
</command>
<precheck>
chkhostname curlhost
@ -99,19 +99,19 @@ chkhostname curlhost
^User-Agent: curl/.*
</strip>
<protocol nonewline="yes">
CONNECT test.remote.example.com:213 HTTP/1.0
Host: test.remote.example.com:213
CONNECT test.remote.example.com.213:%HTTPPORT HTTP/1.0
Host: test.remote.example.com.213:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:213 HTTP/1.0
Host: test.remote.example.com:213
CONNECT test.remote.example.com.213:%HTTPPORT HTTP/1.0
Host: test.remote.example.com.213:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=
Proxy-Connection: Keep-Alive
POST /path/2130002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.example.com:213
Host: test.remote.example.com.213:%HTTPPORT
Accept: */*
Content-Length: 6
Content-Type: application/x-www-form-urlencoded

View File

@ -15,11 +15,11 @@ followlocation
<reply>
# this is returned first since we get no proxy-auth
<data nocheck="yes">
<connect nocheck="yes">
HTTP/1.1 405 Method Not Allowed swsclose
And you should ignore this data.
</data>
</connect>
</reply>
@ -32,7 +32,7 @@ http
HTTP proxy CONNECT to proxy returning 405
</name>
<command>
http://test.remote.example.com:217/path/2170002 --proxy http://%HOSTIP:%HTTPPORT --proxytunnel -w "%{http_code} %{http_connect}\n"
http://test.remote.example.com.217:%HTTPPORT/path/2170002 --proxy http://%HOSTIP:%HTTPPORT --proxytunnel -w "%{http_code} %{http_connect}\n"
</command>
</client>
@ -42,8 +42,8 @@ http://test.remote.example.com:217/path/2170002 --proxy http://%HOSTIP:%HTTPPORT
^User-Agent: curl/.*
</strip>
<protocol>
CONNECT test.remote.example.com:217 HTTP/1.1
Host: test.remote.example.com:217
CONNECT test.remote.example.com.217:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.217:%HTTPPORT
Proxy-Connection: Keep-Alive
</protocol>

View File

@ -13,23 +13,23 @@ HTTP proxy NTLM auth
<reply>
# this is returned first since we get no proxy-auth
<data1001>
<connect1001>
HTTP/1.0 407 Authorization Required to proxy me my dear
Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
Content-Length: 1033
And you should ignore this data.
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQz
</data1001>
</connect1001>
# This is supposed to be returned when the server gets the second
# Authorization: NTLM line passed-in from the client
<data1002>
<connect1002>
HTTP/1.1 200 Things are fine in proxy land
Server: Microsoft-IIS/5.0
Content-Type: text/html; charset=iso-8859-1
</data1002>
</connect1002>
# this is returned when we get a GET!
<data2>
@ -89,7 +89,7 @@ CURL_GETHOSTNAME=curlhost
LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
</setenv>
<command>
http://test.remote.example.com:265/path/2650002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
http://test.remote.example.com.265:%HTTPPORT/path/2650002 --proxy http://%HOSTIP:%HTTPPORT --proxy-user silly:person --proxy-ntlm --proxytunnel -d "postit"
</command>
<precheck>
chkhostname curlhost
@ -102,19 +102,19 @@ chkhostname curlhost
^User-Agent: curl/.*
</strip>
<protocol nonewline="yes">
CONNECT test.remote.example.com:265 HTTP/1.1
Host: test.remote.example.com:265
CONNECT test.remote.example.com.265:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.265:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
Proxy-Connection: Keep-Alive
CONNECT test.remote.example.com:265 HTTP/1.1
Host: test.remote.example.com:265
CONNECT test.remote.example.com.265:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.265:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAABQAFAHAAAAAIAAgAdQAAAAAAAAAAAAAABoKBAKAeQjzKtCQ7ubW8S6MN7B59436GAxPu0CVROwwNBsgxML49gcbAXLT/bU+H5wrS9XNpbGx5Y3VybGhvc3Q=
Proxy-Connection: Keep-Alive
POST /path/2650002 HTTP/1.1
User-Agent: curl/7.12.3-CVS (i686-pc-linux-gnu) libcurl/7.12.3-CVS OpenSSL/0.9.6b zlib/1.1.4
Host: test.remote.example.com:265
Host: test.remote.example.com.265:%HTTPPORT
Accept: */*
Content-Length: 6
Content-Type: application/x-www-form-urlencoded

View File

@ -14,6 +14,12 @@ proxytunnel
#
# Server-side
<reply>
<connect>
HTTP/1.1 200 OK
Connected-fine: sure
</connect>
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
@ -24,7 +30,8 @@ Content-Length: 9
contents
</data>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
HTTP/1.1 200 OK
Connected-fine: sure
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
@ -47,7 +54,7 @@ http-proxy
HTTP CONNECT with proxytunnel getting two URLs from the same host
</name>
<command>
http://remotesite.com:%HTTPPORT/we/want/that/page/275 -p -x %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself http://remotesite.com:%HTTPPORT/we/want/that/page/275
http://remotesite.com.275:%HTTPPORT/we/want/that/page/275 -p -x %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself http://remotesite.com.275:%HTTPPORT/we/want/that/page/275
</command>
</client>
@ -58,8 +65,8 @@ http://remotesite.com:%HTTPPORT/we/want/that/page/275 -p -x %HOSTIP:%PROXYPORT -
^User-Agent:.*
</strip>
<proxy>
CONNECT remotesite.com:%HTTPPORT HTTP/1.1
Host: remotesite.com:%HTTPPORT
CONNECT remotesite.com.275:%HTTPPORT HTTP/1.1
Host: remotesite.com.275:%HTTPPORT
Proxy-Authorization: Basic eW91YXJlOnlvdXJzZWxm
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Proxy-Connection: Keep-Alive
@ -68,12 +75,12 @@ Proxy-Connection: Keep-Alive
<protocol>
GET /we/want/that/page/275 HTTP/1.1
Authorization: Basic aWFtOm15c2VsZg==
Host: remotesite.com:%HTTPPORT
Host: remotesite.com.275:%HTTPPORT
Accept: */*
GET /we/want/that/page/275 HTTP/1.1
Authorization: Basic aWFtOm15c2VsZg==
Host: remotesite.com:%HTTPPORT
Host: remotesite.com.275:%HTTPPORT
Accept: */*
</protocol>

View File

@ -11,12 +11,11 @@ proxytunnel
# Server-side
<reply>
# this is returned first since we get no proxy-auth
<data nocheck="yes">
<connect nocheck="yes">
HTTP/1.1 405 Method Not Allowed swsclose
And you should ignore this data.
</data>
</connect>
</reply>
@ -29,15 +28,15 @@ http
HTTP proxy CONNECT with custom User-Agent header
</name>
<command>
http://test.remote.example.com:287/path/287 -H "User-Agent: looser/2007" --proxy http://%HOSTIP:%HTTPPORT --proxytunnel
http://test.remote.example.com.287:%HTTPPORT/path/287 -H "User-Agent: looser/2007" --proxy http://%HOSTIP:%HTTPPORT --proxytunnel
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
CONNECT test.remote.example.com:287 HTTP/1.1
Host: test.remote.example.com:287
CONNECT test.remote.example.com.287:%HTTPPORT HTTP/1.1
Host: test.remote.example.com.287:%HTTPPORT
Proxy-Connection: Keep-Alive
User-Agent: looser/2007

View File

@ -9,6 +9,17 @@ FAILURE
</keywords>
</info>
# Server-side
<reply>
<connect nocheck="yes">
HTTP/1.1 405 Method Not Allowed swsclose
And you should ignore this data.
</connect>
</reply>
# Client-side
<client>
<features>
@ -21,7 +32,7 @@ https
HTTPS GET over HTTP proxy fails
</name>
<command>
-k -U fake:user -x %HOSTIP:%HTTPPORT https://bad.fakeurl-to.test/slash/302
-k -U fake:user -x %HOSTIP:%HTTPPORT https://bad.fakeurl-to.test:302/slash/302
</command>
</client>

View File

@ -16,6 +16,10 @@ multi
<servercmd>
connection-monitor
</servercmd>
<connect>
HTTP/1.1 200 Mighty fine indeed
</connect>
<data>
HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT
@ -51,7 +55,7 @@ lib503
simple multi http:// through proxytunnel with authentication info
</name>
<command>
http://%HOSTIP:%HTTPPORT/503 %HOSTIP:%PROXYPORT
http://machine.503:%HTTPPORT/503 %HOSTIP:%PROXYPORT
</command>
<file name="log/test503.txt">
foo
@ -65,8 +69,8 @@ moo
# Verify data after the test has been "shot"
<verify>
<proxy>
CONNECT %HOSTIP:%HTTPPORT HTTP/1.1
Host: %HOSTIP:%HTTPPORT
CONNECT machine.503:%HTTPPORT HTTP/1.1
Host: machine.503:%HTTPPORT
Proxy-Authorization: Basic dGVzdDppbmc=
Proxy-Connection: Keep-Alive
@ -74,7 +78,7 @@ Proxy-Connection: Keep-Alive
<protocol>
GET /503 HTTP/1.1
Authorization: Basic dGVzdDppbmc=
Host: %HOSTIP:%HTTPPORT
Host: machine.503:%HTTPPORT
Accept: */*
[DISCONNECT]

View File

@ -24,6 +24,10 @@ Content-Length: 9
contents
</data>
<connect>
HTTP/1.1 200 Mighty fine indeed
</connect>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
@ -49,7 +53,7 @@ http-proxy
HTTP 1.0 CONNECT with proxytunnel and proxy+host Basic authentication
</name>
<command>
http://%HOSTIP:%HTTPPORT/we/want/that/page/80 -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself
http://test.80:%HTTPPORT/we/want/that/page/80 -p --proxy1.0 %HOSTIP:%PROXYPORT --user iam:myself --proxy-user youare:yourself
</command>
</client>
@ -60,8 +64,8 @@ http://%HOSTIP:%HTTPPORT/we/want/that/page/80 -p --proxy1.0 %HOSTIP:%PROXYPORT -
^User-Agent:.*
</strip>
<proxy>
CONNECT %HOSTIP:%HTTPPORT HTTP/1.0
Host: %HOSTIP:%HTTPPORT
CONNECT test.80:%HTTPPORT HTTP/1.0
Host: test.80:%HTTPPORT
Proxy-Authorization: Basic eW91YXJlOnlvdXJzZWxm
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Proxy-Connection: Keep-Alive
@ -71,7 +75,7 @@ Proxy-Connection: Keep-Alive
GET /we/want/that/page/80 HTTP/1.1
Authorization: Basic aWFtOm15c2VsZg==
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Host: %HOSTIP:%HTTPPORT
Host: test.80:%HTTPPORT
Accept: */*
</protocol>

View File

@ -21,6 +21,10 @@ Content-Length: 9
contents
</data>
<connect>
HTTP/1.1 200 Mighty fine indeed
</connect>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
@ -46,7 +50,7 @@ http-proxy
HTTP over proxy-tunnel with site authentication
</name>
<command>
http://%HOSTIP:%HTTPPORT/we/want/that/page/83 -p -x %HOSTIP:%PROXYPORT --user iam:myself
http://test.83:%HTTPPORT/we/want/that/page/83 -p -x %HOSTIP:%PROXYPORT --user iam:myself
</command>
</client>
@ -57,9 +61,9 @@ http://%HOSTIP:%HTTPPORT/we/want/that/page/83 -p -x %HOSTIP:%PROXYPORT --user ia
^User-Agent:.*
</strip>
<proxy>
CONNECT %HOSTIP:%HTTPPORT HTTP/1.1
CONNECT test.83:%HTTPPORT HTTP/1.1
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Host: %HOSTIP:%HTTPPORT
Host: test.83:%HTTPPORT
Proxy-Connection: Keep-Alive
</proxy>
@ -67,7 +71,7 @@ Proxy-Connection: Keep-Alive
GET /we/want/that/page/83 HTTP/1.1
Authorization: Basic aWFtOm15c2VsZg==
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Host: %HOSTIP:%HTTPPORT
Host: test.83:%HTTPPORT
Accept: */*
</protocol>

View File

@ -11,14 +11,14 @@ FAILURE
#
# Server-side
<reply>
<data nocheck="yes">
<connect nocheck="yes">
HTTP/1.1 407 Needs proxy authentication
Server: test-server/fake swsclose yesyes
Proxy-Authenticate: Basic "oh please"
Connection: close
bing
</data>
</connect>
</reply>
#

View File

@ -21,6 +21,10 @@ Content-Length: 9
contents
</data>
<connect>
HTTP/1.1 200 Mighty fine indeed
</connect>
<datacheck>
HTTP/1.1 200 Mighty fine indeed
@ -46,7 +50,7 @@ http-proxy
HTTP over proxytunnel using POST
</name>
<command>
http://%HOSTIP:%HTTPPORT/we/want/that/page/95 -p -x %HOSTIP:%PROXYPORT -d "datatopost=ohthatsfunyesyes"
http://test.95:%HTTPPORT/we/want/that/page/95 -p -x %HOSTIP:%PROXYPORT -d "datatopost=ohthatsfunyesyes"
</command>
</client>
@ -57,16 +61,16 @@ http://%HOSTIP:%HTTPPORT/we/want/that/page/95 -p -x %HOSTIP:%PROXYPORT -d "datat
^User-Agent:.*
</strip>
<proxy>
CONNECT %HOSTIP:%HTTPPORT HTTP/1.1
CONNECT test.95:%HTTPPORT HTTP/1.1
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Host: %HOSTIP:%HTTPPORT
Host: test.95:%HTTPPORT
Proxy-Connection: Keep-Alive
</proxy>
<protocol nonewline="yes">
POST /we/want/that/page/95 HTTP/1.1
User-Agent: curl/7.10.7-pre2 (i686-pc-linux-gnu) libcurl/7.10.7-pre2 OpenSSL/0.9.7a zlib/1.1.3
Host: %HOSTIP:%HTTPPORT
Host: test.95:%HTTPPORT
Accept: */*
Content-Length: 27
Content-Type: application/x-www-form-urlencoded

View File

@ -21,6 +21,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
lib1509 \
lib1900 \
lib2033
@ -326,6 +327,10 @@ lib1508_SOURCES = lib1508.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1508_LDADD = $(TESTUTIL_LIBS)
lib1508_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1508
lib1509_SOURCES = lib1509.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1509_LDADD = $(TESTUTIL_LIBS)
lib1509_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1509
lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1900_CPPFLAGS = $(AM_CPPFLAGS)

81
tests/libtest/lib1509.c Normal file
View File

@ -0,0 +1,81 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, 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 http://curl.haxx.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.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define VERBOSE 0
size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream);
size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream);
long realHeaderSize = 0;
int test(char *URL)
{
CURL *curl;
long headerSize;
CURLcode res=CURLE_OK;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
easy_setopt(curl, CURLOPT_WRITEFUNCTION, *WriteOutput);
easy_setopt(curl, CURLOPT_HEADERFUNCTION, *WriteHeader);
easy_setopt(curl, CURLOPT_HEADER, 1L);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &headerSize);
printf("header length is ........: %lu\n", headerSize);
printf("header length should be..: %lu\n", realHeaderSize);
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
size_t WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream)
{
fwrite(ptr, size, nmemb, stream);
return nmemb * size;
}
size_t WriteHeader(void *ptr, size_t size, size_t nmemb, void *stream)
{
(void)ptr;
(void)stream;
realHeaderSize += size * nmemb;
return nmemb * size;
}

View File

@ -88,6 +88,8 @@ static bool prevbounce=FALSE; /* instructs the server to increase the part
struct httprequest {
char reqbuf[REQBUFSIZ]; /* buffer area for the incoming request */
bool connect_request; /* if a CONNECT */
unsigned short connect_port; /* the port number CONNECT used */
size_t checkindex; /* where to start checking of the request */
size_t offset; /* size of the incoming request */
long testno; /* test number found in the request */
@ -111,7 +113,6 @@ struct httprequest {
int prot_version; /* HTTP version * 10 */
bool pipelining; /* true if request is pipelined */
int callcount; /* times ProcessRequest() gets called */
unsigned short connect_port; /* the port number CONNECT used */
bool connmon; /* monitor the state of the connection, log disconnects */
int done_processing;
};
@ -166,11 +167,8 @@ const char *serverlogfile = DEFAULT_LOGFILE;
#define END_OF_HEADERS "\r\n\r\n"
enum {
DOCNUMBER_NOTHING = -7,
DOCNUMBER_QUIT = -6,
DOCNUMBER_BADCONNECT = -5,
DOCNUMBER_INTERNAL= -4,
DOCNUMBER_CONNECT = -3,
DOCNUMBER_NOTHING = -4,
DOCNUMBER_QUIT = -3,
DOCNUMBER_WERULEZ = -2,
DOCNUMBER_404 = -1
};
@ -181,14 +179,6 @@ static const char *end_of_headers = END_OF_HEADERS;
static const char *docquit =
"HTTP/1.1 200 Goodbye" END_OF_HEADERS;
/* sent as reply to a CONNECT */
static const char *docconnect =
"HTTP/1.1 200 Mighty fine indeed" END_OF_HEADERS;
/* sent as reply to a "bad" CONNECT */
static const char *docbadconnect =
"HTTP/1.1 501 Forbidden you fool" END_OF_HEADERS;
/* send back this on 404 file not found */
static const char *doc404 = "HTTP/1.1 404 Not Found\r\n"
"Server: " SWSVERSION "\r\n"
@ -342,8 +332,8 @@ static int parse_servercmd(struct httprequest *req)
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", req->testno);
logmsg(" [1] Error opening file: %s", filename);
logmsg(" Couldn't open test file %ld", req->testno);
req->open = FALSE; /* closes connection */
return 1; /* done */
}
@ -533,6 +523,8 @@ static int ProcessRequest(struct httprequest *req)
doc, prot_major, prot_minor);
logmsg("%s", logbuf);
req->connect_request = TRUE;
if(req->prot_version == 10)
req->open = FALSE; /* HTTP 1.0 closes connection by default */
@ -557,55 +549,45 @@ static int ProcessRequest(struct httprequest *req)
else
req->connect_port = curlx_ultous(ulnum);
}
}
}
if(!strncmp(doc, "bad", 3))
/* if the host name starts with bad, we fake an error here */
req->testno = DOCNUMBER_BADCONNECT;
else if(!strncmp(doc, "test", 4))
/* if the host name starts with test, the port number used in the
CONNECT line will be used as test number! */
req->testno = req->connect_port?req->connect_port:DOCNUMBER_CONNECT;
if(req->testno == DOCNUMBER_NOTHING) {
/* Still no test case number. Try to get the the number off the last dot
instead, IE we consider the TLD to be the test number. Test 123 can
then be written as "example.com.123". */
/* find the last dot */
ptr = strrchr(doc, '.');
/* get the number after it */
if(ptr) {
ptr++; /* skip the dot */
req->testno = strtol(ptr, &ptr, 10);
if(req->testno > 10000) {
req->partno = req->testno % 10000;
req->testno /= 10000;
logmsg("found test %d in requested host name", req->testno);
}
else
req->testno = req->connect_port?DOCNUMBER_CONNECT:DOCNUMBER_BADCONNECT;
req->partno = 0;
/* find and parse <servercmd> for this test */
sprintf(logbuf, "Requested test number %ld part %ld (from host name)",
req->testno, req->partno);
logmsg("%s", logbuf);
}
if(!req->testno) {
logmsg("Did not find test number in PATH");
req->testno = DOCNUMBER_404;
}
else
parse_servercmd(req);
}
else {
/* there was no trailing slash and it wasn't CONNECT, then we get the
the number off the last dot instead, IE we consider the TLD to be
the test number. Test 123 can then be written as
"example.com.123". */
/* find the last dot */
ptr = strrchr(doc, '.');
/* get the number after it */
if(ptr) {
ptr++; /* skip the dot */
req->testno = strtol(ptr, &ptr, 10);
if(req->testno > 10000) {
req->partno = req->testno % 10000;
req->testno /= 10000;
}
else
req->partno = 0;
sprintf(logbuf, "Requested test number %ld part %ld (from host name)",
req->testno, req->partno);
logmsg("%s", logbuf);
}
if(!req->testno) {
logmsg("Did not find test number in PATH");
req->testno = DOCNUMBER_404;
}
else
parse_servercmd(req);
}
}
}
else if((req->offset >= 3) && (req->testno == DOCNUMBER_NOTHING)) {
@ -822,7 +804,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
dump = fopen(dumpfile, "ab");
} while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
logmsg("[2] Error opening file %s error: %d %s",
dumpfile, error, strerror(error));
logmsg("Failed to write request input ");
return;
@ -868,6 +850,7 @@ static void init_httprequest(struct httprequest *req)
}
req->testno = DOCNUMBER_NOTHING;
req->partno = 0;
req->connect_request = FALSE;
req->open = TRUE;
req->auth_req = FALSE;
req->auth = FALSE;
@ -1007,10 +990,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
const char *responsedump = is_proxy?RESPONSE_PROXY_DUMP:RESPONSE_DUMP;
static char weare[256];
char partbuf[80]="data";
logmsg("Send response test%ld section <data%ld>", req->testno, req->partno);
switch(req->rcmd) {
default:
case RCMD_NORMALREQ:
@ -1056,17 +1035,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
msglen, msgbuf);
buffer = weare;
break;
case DOCNUMBER_INTERNAL:
logmsg("Bailing out due to internal error");
return -1;
case DOCNUMBER_CONNECT:
logmsg("Replying to CONNECT");
buffer = docconnect;
break;
case DOCNUMBER_BADCONNECT:
logmsg("Replying to a bad CONNECT");
buffer = docbadconnect;
break;
case DOCNUMBER_404:
default:
logmsg("Replying to with a 404");
@ -1077,17 +1045,25 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
count = strlen(buffer);
}
else {
char partbuf[80];
char *filename = test2file(req->testno);
if(0 != req->partno)
sprintf(partbuf, "data%ld", req->partno);
/* select the <data> tag for "normal" requests and the <connect> one
for CONNECT requests (within the <reply> section) */
const char *section= req->connect_request?"connect":"data";
if(req->partno)
sprintf(partbuf, "%s%ld", section, req->partno);
else
sprintf(partbuf, "%s", section);
logmsg("Send response test%ld section <%s>", req->testno, partbuf);
stream=fopen(filename, "rb");
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
logmsg(" [3] Error opening file: %s", filename);
return 0;
}
else {
@ -1111,8 +1087,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
if(!stream) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
logmsg(" [4] Error opening file: %s", filename);
if(ptr)
free(ptr);
return 0;
@ -1156,7 +1131,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
if(!dump) {
error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", responsedump);
logmsg(" [5] Error opening file: %s", responsedump);
if(ptr)
free(ptr);
if(cmd)
@ -1389,8 +1364,8 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
static void http_connect(curl_socket_t *infdp,
curl_socket_t rootfd,
struct httprequest *req,
const char *ipaddr)
const char *ipaddr,
unsigned short ipport)
{
curl_socket_t serverfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
curl_socket_t clientfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD};
@ -1422,7 +1397,7 @@ static void http_connect(curl_socket_t *infdp,
if(got_exit_signal)
goto http_connect_cleanup;
serverfd[CTRL] = connect_to(ipaddr, req->connect_port);
serverfd[CTRL] = connect_to(ipaddr, ipport);
if(serverfd[CTRL] == CURL_SOCKET_BAD)
goto http_connect_cleanup;
@ -1539,7 +1514,7 @@ static void http_connect(curl_socket_t *infdp,
/* skip this and close the socket if err < 0 */
if(err >= 0) {
err = send_doc(datafd, &req2);
if(!err && (req2.testno == DOCNUMBER_CONNECT)) {
if(!err && req2.connect_request) {
/* sleep to prevent triggering libcurl known bug #39. */
for(loop = 2; (loop > 0) && !got_exit_signal; loop--)
wait_ms(250);
@ -1847,7 +1822,8 @@ static curl_socket_t accept_connection(curl_socket_t sock)
/* returns 1 if the connection should be serviced again immediately, 0 if there
is no data waiting, or < 0 if it should be closed */
static int service_connection(curl_socket_t msgsock, struct httprequest *req,
curl_socket_t listensock, const char *hostport)
curl_socket_t listensock,
const char *connecthost)
{
if(got_exit_signal)
return -1;
@ -1878,17 +1854,7 @@ static int service_connection(curl_socket_t msgsock, struct httprequest *req,
if(got_exit_signal)
return -1;
if(DOCNUMBER_CONNECT == req->testno) {
/* a CONNECT request, setup and talk the tunnel */
if(!is_proxy) {
logmsg("received CONNECT but isn't running as proxy! EXIT");
}
else
http_connect(&msgsock, listensock, req, hostport);
return -1;
}
if((req->testno < 0) && (req->testno != DOCNUMBER_CONNECT)) {
if(req->testno < 0) {
logmsg("special request received, no persistency");
return -1;
}
@ -1897,6 +1863,18 @@ static int service_connection(curl_socket_t msgsock, struct httprequest *req,
return -1;
}
if(req->connect_request) {
/* a CONNECT request, setup and talk the tunnel */
if(!is_proxy) {
logmsg("received CONNECT but isn't running as proxy!");
return 1;
}
else {
http_connect(&msgsock, listensock, connecthost, req->connect_port);
return -1;
}
}
/* if we got a CONNECT, loop and get another request as well! */
if(req->open) {
@ -1904,9 +1882,6 @@ static int service_connection(curl_socket_t msgsock, struct httprequest *req,
return 1;
}
if(req->testno == DOCNUMBER_CONNECT)
return 1;
return -1;
}
@ -1923,7 +1898,9 @@ int main(int argc, char *argv[])
int error;
int arg=1;
long pid;
const char *hostport = "127.0.0.1";
const char *connecthost = "127.0.0.1";
/* a default CONNECT port is basically pointless but still ... */
size_t socket_idx;
memset(&req, 0, sizeof(req));
@ -1993,14 +1970,15 @@ int main(int argc, char *argv[])
}
}
else if(!strcmp("--connect", argv[arg])) {
/* store the connect host, but also use this as a hint that we
run as a proxy and do a few different internal choices */
/* The connect host IP number that the proxy will connect to no matter
what the client asks for, but also use this as a hint that we run as
a proxy and do a few different internal choices */
arg++;
if(argc>arg) {
hostport = argv[arg];
connecthost = argv[arg];
arg++;
is_proxy = TRUE;
logmsg("Run as proxy, CONNECT to %s", hostport);
logmsg("Run as proxy, CONNECT to host %s", connecthost);
}
}
else {
@ -2184,7 +2162,8 @@ int main(int argc, char *argv[])
/* Service this connection until it has nothing available */
do {
rc = service_connection(all_sockets[socket_idx], &req, sock, hostport);
rc = service_connection(all_sockets[socket_idx], &req, sock,
connecthost);
if(got_exit_signal)
goto sws_cleanup;