How to simulate HTTP requests. For example, I want to simulate request to insert data into my database, to check safety and reliability of my program. Are there some good tools ?
-
You mean a tool that can *make* HTTP requests? One industry standard is curl: http://curl.haxx.se/ (edit: ah, you may mean load testing - Google eg. `server load testing tools`) This isn't a good question for SO, some Googling will get you all the solutions you need. – Pekka Sep 27 '13 at 01:52
-
I test my web applications by `Acunetix` ,you can modify requests with it too. but if you only want to modify requests, Use [Tamper data](https://addons.mozilla.org/en-US/firefox/addon/tamper-data) – undone Sep 27 '13 at 01:52
5 Answers
For *nix OS you can use telnet, curl or wget utilites:
Telnet:
user@host:~$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /api.php?param1=10¶m2=20 HTTP/1.1 # here is your request params
Host: localhost # required HTTP header
# double ENTER for sending request
Check telnet man-page of your OS for advanced options.
Curl:
user@host:~$ curl \
--header 'Host: localhost' \
--user-agent 'Mozilla/5.0 (Linux x86_64; rv:10.0.12) Gecko/ Firefox/10.0.12' \
--no-keepalive \
http://localhost/api.php?param1=10¶m2=20
Check curl man-page of your OS for advanced options.
Wget:
user@host:~$ wget http://localhost/api.php?param1=10¶m2=20
Check wget man-page of your OS for advanced options.
FYI if you choose curl then you'll allow to use power of *nix shell: grep, sed, output redirection and a lot of other useful stuff.

- 1
- 1

- 13,817
- 5
- 55
- 55
If you want to try from the server side cURL is definitely the easiest way. Since you tagged this question with PHP here is a simple PHP script that simulates a POST request.
<?php
$url = "http://yoursite.com/yourscript.php";
$postdata = array (
"name" => "Joe",
"address" => "Some street",
"state" => "NY",
);
$req = curl_init($url);
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($req);
If you want to try requests from the browser there are very good extensions for both Chrome and Firefox. For example (for chrome) POSTMAN or Advanced REST client.

- 1,766
- 2
- 14
- 15
In order to test your PHP application, you can use a testing framework like: SimpleTest
<?php
require_once('simpletest/browser.php');
$browser = &new SimpleBrowser();
$browser->get('http://php.net/');
$browser->click('reporting bugs');
$browser->click('statistics');
$page = $browser->click('PHP 5 bugs only');
preg_match('/status=Open.*?by=Any.*?(\d+)<\/a>/', $page, $matches);
print $matches[1];
?>

- 3,575
- 4
- 34
- 47
HTTPie consists of a single "http" command designed for painless debugging and interaction with HTTP servers, RESTful APIs, and web services. It can be used on all platforms.
Use Github API to post a comment on an issue with authentication:
$ http -a USERNAME POST https://api.github.com/repos/jkbrzt/httpie/issues/83/comments body='HTTPie is awesome! :heart:'

- 1,473
- 18
- 19
I think you can try HTTP request at https://w3webtool.com/http-request-method
You can fill out your parameter and simulate your http request method.