Hurkyl said:
davee: what is the problem are you really trying to solve? What is the problem for which you thought HTTP redirects would be a solution for?
I'm writing a login system for my own custom web application. So, embedded in most every CGI within the application is the login piece.
Now, what happens when your login expires? Let's say you logged in, and then left your browser sitting on "Page A" in the middle of the application. Now, you come back after the login expires. Your page is still there, so you click one of the links to "Page B" with parameters 1, 2, 3. Well, "Page B" checks your login and finds out it's expired. So what does it do? It sends you to the login page. Actually, it usurps the call, and shows the login screen on the same URL that "Page B" was on. Now, you log in. Where does it take you next?
If you're kind to your users, you take them back to "Page B", with parameters 1, 2, 3. You could just take them back to the "home" area or wherever you want. But if you're nice, you take them where they were trying to click. And the way that I do that is by saving all the parameters in hidden fields on the login screen.
Anyway, submitting the login form sends the browser to a login verification CGI, which authenticates the user, and then attempts to send them back on their merry way to "Page B" with parameters 1, 2, 3. And you do that with HTTP redirects, because other methods aren't as good. Generally for two reasons:
1) Users can disable meta-refreshes, JavaScript, plugins, etc. Some browsers also don't support them (like some mobile devices or more primitive text-based browsers).
2) The "bounce" page is generally NOT saved in the browser history with HTTP redirects, whereas meta-refreshes, JavaScript, etc, ARE kept. So if a user tries to navigate with the "Back" button, they can't get beyond the redirect page (although browsers these days typically allow you to "jump" through your history). If they go back to the redirect page, they just get bumped forward again.
That second reason is also the recommended method of form submission for things like credit card information, etc, because again, the user's browser is very unlikely to hit it again since it's not in the browser history. If it DID try to navigate to the page again, and decided not to use a cached copy, it would submit the request again, possibly double-billing a credit card (or doing whatever action you DON'T want your users to repeat). In this particular instance, it's not a big deal, since all it would do is re-log them in. But in general, there are a lot of cases where using an HTTP redirect really IS the preferred way of doing things for the above reasons.
[edit]Actually, now that I think about it, you probably DON'T want them to be able to just log in again by re-posting. That would allow someone to snag the browser and just do a re-post of the form to reload, and thereby log them in. Of course, if the browser saves the username/password, they're screwed anyway, but that's not a security hole I can circumvent, without doing something crazy.[/edit]
But back to the issue at hand. Using HTTP redirects (the way I'd prefer to do things), I only know how to force a GET query. But... if instead of parameters 1, 2, 3, let's say there were 500 different parameters! That's enough to overflow the GET query, and it means that the subsequent call to "Page B" won't be complete. Depending on the browser and webserver, I'm not really sure HOW it would handle this. I had thought it was about a 1K limit, but looks like it's more like 2K-8K generally. But regardless, it's certainly possible to go beyond that limit.
Now, there are a lot of ways to handle this:
1) If possible, use HTTP redirects using a POST to get the user back to their desired location.
2) I could say screw it, and impolitely force the user to their "home" area, losing their desired path. (This can annoy users if, say, they spent a long time filling out a form and then lost the information, forcing them to fill it out again)
3) I could redirect using meta-refreshes, JavaScript, or what-have-you.
4) I could rebuild the Login module so that rather than forcing you to the authentication CGI, it just keeps you on the existing CGI, but gracefully passes back all the parameters (passed exactly as they were on the original form), so that the successful login results in a near duplication of their former attempt.
5) I could also rebuild the Login module to store the POST parameters in a time-indexed file, and pull them out of there on the subsequent page request-- but that requires integrating my login module with the parameter processing, which is pretty sketchy.
Now, I figured the best option was #1. And I think I'd opt for #4 before I resort to #3 or #2. After all, I'm hoping I can re-use this login system in the future, so I'd like it to be as useful going forward as possible.
So, that's what I'm shooting for. If it's possible, great! If it's not, then oh well, I'll figure something else out.
DaveE