Take the 2-minute tour ×  I'm writing a script which tries to
access a web-page through HTTP. (The real page is not public, so
I'll use an example page to explain my question.) For example,
I'm trying to GET the page example.com/mypage. The server
returns 301, and when I check the Location header I see it's
value is... http://example.com/mypage - that is the EXACT same
location I was trying to GET from the first place! How is my
script supposed to get the page? Before seeing this I thought I
should check the Location header and try to fetch it - but as
it's the same location that would get me in an infinite loop!
Of course, when I try to browse the page with a browser I get
the contents without a problem.  So my questions are:  1) What
does it mean that the Location header matches the location I
asked for perfectly with a 301 status?  2) How come the browser
can display the page?  3) Is there any way to debug what goes on
through the browser (e.g. to ask the browser for the response
headers or something; ask