I wanted to know whether/how browsers do check for redirection loop.
I use this little GatewayScript in a loopback XML Firewall Service, listening on port 2345, with "process messages without body" flag set (for handling GET requests):
💻 cat 303.js
var headers = require('header-metadata');
headers['response'].statusCode = 303;
22.214.171.124 is the IP address of the appliance where I installed the service.
For testing "curl -v" shows that it does what it should:
💻 curl -v http://126.96.36.199:2345; echo
* About to connect() to 188.8.131.52 port 2345 (#0)
* Trying 184.108.40.206... connected
* Connected to 220.127.116.11 (18.104.22.168) port 2345 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 22.214.171.124:2345
> Accept: */*
< HTTP/1.1 303 See Other
< User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
< Host: 126.96.36.199:2345
< X-Global-Transaction-ID: 99057
< Via: 1.1 303
< X-Client-IP: 188.8.131.52
< Location: http://184.108.40.206:2345/0.9617025442421436
< Content-Type: text/plain
< Transfer-Encoding: chunked
* Connection #0 to host 220.127.116.11 left intact
* Closing connection #0
As can be seen the HTTP return code 303 gets set, and the Location header gets set. Appending "Math.random()" to the URL was the simplest way I could think of to generate random URLs.
I entered "http://18.104.22.168:2345/" in Chrome and Firefox. Chrome reports "This webpage has a redirect loop", Firefox reports "The page isn't redirecting properly".
Then I took packet captures for both Firefox and Chrome. Follow TCP Stream on "tcp.port==2345" filter showed exactly 21 GET requets and 303 responses for both.
Opera browser deals with redirects differently, it stops after 11 GET requests/303 response with an error page stating
The URL was redirected to http://22.214.171.124:2345/0.6544099773745984. Please click the link to go there.
Generated by Opera.".