Solved

Faking a POST

Posted on 1998-05-30
4
166 Views
Last Modified: 2013-12-25
I'm building a program that automates some web-research that I do on a regular basis. The prog is based around a simple telnet client and connects to various webservers to get it's info.

GET stuff is easy but even though I have the original RFC documents I cannot seem to find a good demonstration of how the POST mechanism works.

I am assuming that it uses a header with the infomation being sent to the CGI going in name = value pairs. Can anyone give me a good example of what these headers look like?

A straight dump of what a browser sends when actioning a FORM with POST method would be perfect.


Thanks
Marty
0
Comment
Question by:mravell
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
faster earned 200 total points
Comment Utility
It is not in a header.

For example:

POST /test.cgi HTTTP/1.0\r\n
Content-Length: 14\r\n
\r\n
name=12&age=21

0
 
LVL 7

Expert Comment

by:faster
Comment Utility
Please note that an empty line is the end of headers, then the body comes which contains the form data.  Content-Length should contain the length of the body.

Normally the request generated by browser is more complex, but the above-mentioned is the ones that really matters.

Below is a real request (when the browser uses to a proxy)

POST http://dilbert.eccs.ap:82/u/EN/dbilogin/cgi/login_main.cgi HTTP/1.0
Accept: application/vnd.ms-excel, application/msword, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Referer: http://dilbert.eccs.ap:82/u/EN/dbilogin/cgi/login_main.cgi?URI=http%3a//dilbert.eccs.ap%3a82/p/EN/home/cgi/DBI_home.cgi
Accept-Language: en-us
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
Host: dilbert.eccs.ap:82
Content-Length: 129
Pragma: No-Cache

postdata...

Refer to RFC1945 for detail.
0
 

Author Comment

by:mravell
Comment Utility
Hi faster,

Thanks for the reply. This is exactly what I needed!

How did you get the example you included in the reply? I have another question open in C and CGI areas asking for a network sniffer utility that would have let me find this stuff out myself. If you have such a beast you could get the points from those Q's as well. (I'd still like to get my hands on such a program)


Thanks
Marty
0
 
LVL 7

Expert Comment

by:faster
Comment Utility
I used my proxy server to get the request from browser, so it is not really a sniffer.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now