in reply to HTTP POST

The error HTTP/1.1 500 Internal Server Error means that some internal error occurred. Look in the web server error log to find a more detailed error description.

Most likely, you have an error in your receiving Perl program.

As for the terminology - you don't "POST to a file" on a webserver, you "send a POST request to an URL on a webserver". That URL is commonly handled by a program, and it does not matter in what language that program is written.

Replies are listed 'Best First'.
Re^2: HTTP POST
by kansaschuck (Sexton) on Mar 10, 2008 at 15:25 UTC
    Maybe I got the basic concept wrong. Isn't POST about the same a 'write'? I want to write a message from my PC over the internet, to a file on a webserver.
    And the final goal, there is a file (.txt) that I just want to zero out. After reading the info remotely I want to empty it and then write an new record in it.

    I'm off studying. UPDATE: # The request URI is not a resource to retrieve; it's usually a program to handle the data you're sending.

      POST requests don't modify files on the server, unless you write a server side script that modifies them.

      Maybe you're confusing it with the PUT request that is used for example in WebDAV?

      A post is not going to write to a file, a post sends data to a program that then does something with it.

      what it sounds like you need to do is write a Perl program on your server, that will accept the data, then write it to your .txt file.

      g_White
        Thanks Monks, I think I got it. An HTTP POST sends data to a program on the other end (POST and EXECUTE). In my case I had PHP take the hand off. So in PHP-land the HTTP POST shows up as an Array of values delivered in $_POST. The PHP program takes it from there (array of passed values) and if coded it can write to a file or anything php can do. My Perl send off below:

        my $req = new HTTP::Request 'POST','http://foobar.com/stuff/post.php';
        $req->content_type('application/x-www-form-urlencoded');

        my $text = "rambling text message here for future use, Dave can hear me. ";
        my $user = "yourusernamehere";
        my $pass = "yourpasswordhere";
        my $number = "44.55";

        $req->content("user=" . $user . "&pass=" . $pass . "&text=" . $text . "&number=" . $number);
        my $res = $ua->request($req);
        print $res->as_string;


        So basically I had two misconceptions:
        1) that POST could just write directly to a remote .txt file.
        2) something else that escaped me at first is that echo and print statements at the server within the remote (php) program are returned to sender. I had the view that POST was sort of one way comms. But it's more POST-EXECUTE-REPLY.