Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


Hi,

I have a script that submits a list of parameters to a server and prints out the result.
#!/usr/bin/perl -w use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)'); use HTTP::Request::Common qw(POST); my $req = (POST 'http://url_to_post', [username => "value", usermail => "value"]); $request = $ua->request($req); $content = $request->content; print $content;

Then I got these message back:
<META HTTP-EQUIV="Expires" CONTENT="0"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <BODY BGCOLOR='#FFFFFF'> The following error has occured getting your search details: No boundary= in CONTENT_TYPE (application/x-www-form-urlencoded) [M000 +55] Have you tried the browser compatibility test page?

My browser should be compatible. Even through I changed to higher level, this erro message always comes out.

Please help

Edit by castaway - added code tags around error

Replies are listed 'Best First'.
Re: Submitting queries to server
by ikegami (Patriarch) on Sep 15, 2005 at 05:15 UTC

    It sounds like the script is expecting the data to be submitted as multipart/form-data (which uses boundaries), not the default application/x-www-form-urlencoded (the module's default). Looking at the <form> element's enctype attribute will tell you what the script requested. Fortunatly, it's easy to tell HTTP::Request::Common to use multipart/form-data:

    my $req = POST( 'http://url_to_post' , Content_Type => 'form-data' , Content => [ username => "value" , usermail => "value" ] );

      Thanks a lot! It works!

      But I got another problem. I don't know why I still can't get my expected result page. That's why I got:
      <META HTTP-EQUIV="Expires" CONTENT="0"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> Finished uploading search details... Press the back button, and force a re-load (refresh) of the page. You +may have to clear the browser cache or close and re-start the browser

      What dose it mean for 'clear the browser cache....'? What should I do to fix up this?
        What does the result page look like when you request it in a browser, specifically the headers? If the site has a form that you can submit for a normal search request, you may want to look at the source of that form page as well to see what they send along.

        It looks like maybe they are doing some sort of detection and incorrectly assuming you re-submitted an old form?