302 response codes are commonly used for URL redirection when the assets on a server have been moved. When a 302 response code is returned it includes a
header key and a
url value. I needed a quick way to verify my web driven application was respecting these redirects. Using Charles you can simulate such a response using the following technique:
Add a new rewrite in Charles (tools -> rewrite):
Adding a rewrite will modify any request/response made to the defined url.
Under location click the add button and add the desired URL to test:
Replace the “url-to-redirect/example-path” with the desired URL to simulate a 302 for.
Using the bottom add button add a rewrite rule for the 302 response code:
This simulates a 302 response code on the URL defined above.
Using the bottom add button add a rewrite rule for header:
Replace “redirect-url” with the desired url to redirect to.
Test the results. Charles should display the first URL with a blue arrow indicating a redirect. If your application is working correctly the redirect should be recorded by charles right after the 302 response.