Closed sm4rk0 closed 8 years ago
I'm sorry, I didn't see the part after making a connection. This part, specifically:
// It might also be a redirection using meta tags.
Using HEAD request would require another connection/GET request to fetch the body in that case and this would introduce unnecessary complexity to the code...
Yup. I'm reluctant to hardcode the type of redirection for each domain for maintenance reasons, but sending a HEAD request first then a GET request if that's not enough would probably be better in most cases.
(Sorry for the late reply, I missed the original comment.)
Currently the application downloads the target URL. But using HEAD method should have the same effect as it has now, only without getting the response body from the server. I've checked this with t.co using Fiddler Web Debugger. There is only one line of code needed:
c.setRequestMethod("HEAD");
before thec.connect();
inResolver.getRedirect()