[cs631apue] How does POST work?

Jan Schaumann jschauma at stevens.edu
Wed Dec 2 20:59:19 EST 2015


jwang81 <jwang81 at stevens.edu> wrote:

> How to post data to cgi-bin/post.cgi from browser?

>From the browser, you'd need to have an HTML form with a
method="post".

But you can also issue POST requests from the command-line:

$ cat request
POST /~jschauma/cgi-bin/post.cgi HTTP/1.1
Host: www.cs.stevens.edu
Content-Length: 7

foo=bar


$ cat request | nc www.cs.stevens.edu 80
HTTP/1.1 200 OK
Date: Thu, 03 Dec 2015 02:18:56 GMT
Server: Apache/2.2.22 (Debian)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html

8c
<html><head><title>Parsing with POST method</title></head><body>
<h2>These were the values sent:</h2>
<p>foo => bar</p>
</p>
</body></html>

0


You can also use curl(1) or wget(1) etc.  Reference their manual pages
for how to post data.

-Jan


More information about the cs631apue mailing list