You should write it so it handles the 302 redirects. Simply read thenew location field out of the response, and create a new request. Oralways use the URL the server is redirecting you to.B.