When voting on a node, the form uses the POST method. This is good. As a change is being made on the server in response to the HTTP Request, this is the right method to use according to the RFC.

However, this does introduce a niggle or two. Happily this should be easy to fix as I try to explain below.

If one wishes to refresh a node after voting on it (to see, for example, if there are any new replies) most browsers will warn the user that they are resubmitting POST data (also a good thing).

Additionally, since the request was made using POST, the URL the browser has visited doesn't include the node id. This makes it troublesome to bookmark the page, or copy/paste the URL to tell somebody else about the node.

  1. Hey. Great answer!
  2. Up vote
  3. Hmm, that will solve Bob's problem. Email a link ... oh.

However, this should be a pretty easy thing to fix (depending on how the modified Everything code that PM runs on is set out). Simply issue a 302 redirect back to the node page after making the changes on the server.

Such code might look something like this (untested):

use strict; use warnings; use Apache::Constants qw(:common REDIRECT); use Apache::Request; # Update. See said it was untested! sub handler { my $r = shift; $r = Apache::Request->instance($r) my $op = $r->param('op'); if (defined $op && $op eq 'vote') { # # Insert code to record votes here # my $node_id = $r->param('node_id') || ''; my $location = "http://" . $r->hostname . "/?node_id=$node_id"; $r->header_out('Location' => $location); return REDIRECT; } # Otherwise carry on and display the page as normal }

In reply to Redirect after post for happy bookmarking and refreshing by dorward

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.