Hi monastry mates, Was coding a simple search engine, where about 10 results are displayed per page. And if the user searches subsequest pages of the same search string, a cookie is used instead of repeating the whole search. But after a few different search strings are entered the page goes to Bad request (HTTP 400). For that session, all pages from the server get 400 error.
my $start_dir = $q->param("dir"); my @search_string = split / /,$q->param("search_string"); my $search_type = $q->param("search_type"); my $start_num = $q->param("start_number"); if ( ! defined ($start_num) ) { $start_num = 0; } @search_string = getWords(@search_string); my $search_url = $c{url}{find_cgi}."?dir=$start_dir&search_type=$searc +h_type&search_string=".fmtSS(@search_string); my $cookie_name = $q->param("search_string")."_dir_".$start_dir; my $cookie_data = $q->cookie($cookie_name); if ( defined ($cookie_data) ) { my %cookie_hash = %{ thaw $cookie_data }; my @search_result = computeRank($search_type,%cookie_hash); printScore($start_num,$search_url,$c{search_list_length},@sear +ch_result); exit; } my %word_score = getWordScore(...........); if ( %word_score ) { my @search_result = computeRank($search_type,%word_score); $cookie_data = freeze \%word_score; my $search_cookie = $q->cookie(-name=>$cookie_name,-value=>$co +okie_data); printScore($start_num,$search_url,$c{search_list_length},@sear +ch_result); } else { print "<p>No results found"; }

In reply to Getting HTTP 400 Bad Request after a few times page reloads by Justudo

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.