Having to check the title
tag from a lot of different websites I needed a tool that would follow HTTP redirects as well as redirects in meta refresh tags. As a fan of Commons HttpClient, I hacked together some code that does the work.
For the impatient: check out the code here.
The code
The actual code is very simple:
- it executes an HTTP GET with a given URL
- follows HTTP redirects
- finally downloads the contents
- checks whether there’s a meta refresh tag
- starts over at 1. if it found such a tag
- returns the content.
Have a look at the class TitleTest
here: the private method doGet
will be most interesting.
Conclusion
I was wondering why there aren’t that many tools out there which support following meta refresh tags. Since a lot of websites use this feature I thought that this would be something a lot of people might want to use when testing their websites.
Hacking a small tool that does the job is very easy though, as demonstrated in this post.