Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active August 17, 2023 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RichardBronosky/363811de1030f85e55b0ab020cf043e7 to your computer and use it in GitHub Desktop.
Save RichardBronosky/363811de1030f85e55b0ab020cf043e7 to your computer and use it in GitHub Desktop.
A oneliner for testing redirects
#!/bin/bash
# The following line defines a bash function and is designed to be copy-pasta-ed into your terminal and used as shown on the last line of this file. I'm only putting it in a script to get it on gist
redir_test(){ curl -svLo /tmp/redir_test.out "$@" 2>&1 | grep -E '^(> Host|> GET|< HTTP|< location|[<>]\s*$)'; }
# BONUS: One super-useful use of this is to test your readiness to respond to future DNS changes. That can be done like so:
# redir_test -H 'Host: www.example.com' https://192.168.0.101/
# This assumes that your server at 192.168.0.101 is set up to serve www.example.com and this simulates what `curl https://www.example.com/` would do if DNS returned 192.168.0.101 when doing a lookup on www.example.com
redir_test "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment