22

What is the simplest way of sending an HTTP POST to a localhost address/port under Windows?

E.g. do any browser plugins exist to do this or could a command be sent in the Chrome Developer Tools / Firebug console?

[Have seen similar q's asked before but the answers mostly seem to recommend the use of Unix tools such as CURL or Websites such as http://www.hurl.it, which preclude sending the request to localhost.]

1
  • After a few more minutes of searching I found a very similar q has actually been asked before here so have voted to close. Commented Jan 10, 2014 at 14:04

3 Answers 3

30

I use Advanced REST Client usually. I assume it works offline too(never tried it though as my Internet is always on).

Advanced REST Client for Chrome

I think the plugin is available for firefox too. Just google Advanced REST Client

EDIT:

Some other cool alternatives:

Paw (My current favourite)

Postman

Sign up to request clarification or add additional context in comments.

Comments

7

if you use Chrome you can go with the DHC by Restlet or with Rest Console.

I think you can find extension like those for firefox too.

Comments

4

I would invoke PHP with a script that does the post.

file send_post.php

<?php
// here I use argv for URL, but you can adapt it however you like
$url = "http://localhost/".$argv[1];
$data = array('var1' => 'value1', 'var2' => 'value2');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)));

$response = file_get_contents($url, false, stream_context_create($options));

// you can echo the response if you're interrested, or just dump it
echo $response;
?>

test file http://localhost/SO/PHP/receive_post.php

<?php print_r ($_POST) ?>

invokation

C:\Dev\PHP\SO\PHP>php send_post.php whatever

Warning: file_get_contents(http://localhost/whatever): 
         failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
         in C:\Dev\PHP\SO\PHP\send_post.php on line 12

C:\Dev\PHP\SO\PHP>php send_post.php SO/PHP/receive_post.php
Array
(
    [var1] => value1
    [var2] => value2
)

1 Comment

Well a batch file might be considered simpler than a GUI. It all depends of your definition of "simple" :). Maybe some other OPs will find that alternative more appealing, who knows?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.