HTTPER command line syntax
HTTPER /role /Timeout=x
IP_addr:port Request Response
- /role
- This option commands HTTPER to act as a
/Client or /Server and can be abbreviated as
/C and /S. Default is /Client.
- /Timeout=
- Time in seconds when the communication
will be aborted if it doesn't terminate itself.
Following examples set the timeout to 5 minutes:
/Timeout=300s, /T:300, -t300.
Value of 0 will switch the timeout off. If the parameter
is omitted, default timeout is 2 minutes for Client
and 10 minutes for Server. You can always abort
HTTPER manually with Ctrl-Break.
- IP_addr
- IP address is mandatory. It must be
given in numeric form as four numbers 0-255 separated with fullstop ".".
The TCP port may follow IP address and is separated with colon ":".
Default is HTTP port :80.
In client role this parameter specifies remote server
which you want to communicate with. In the case of HTTPER
server the IP address represents interface which
the server should bind to. In most cases the special local
address 0.0.0.0 will do the job.
- Request
- When HTTPER is used as a client,
Request specifies existing file with prepared
request.
In server role, the Request sets the name of file
where the client's request will be stored. Any existing file with
this name will be overwritten.
- Response
- HTTPER client writes received Response
to this file.
In server role this parameter specifies an existing file
which will be returned to client.
As already mentioned, both Request and Response
contain a header and optional message body. HTTPER is able to detach
these two components into two separate files and, vice versa, to join
separate header and body files before sending them away.
All you have to do is write two file names separated with
plus sign "+" instead of single file.
Always put at least one space on both sides of "+", e.g.
HTTPER /C 200.100.50.25 Request.TXT ResponseHeader.TXT + Content.html
Server's response will disjoin, the header goes to ResponseHeader.TXT
and data to Content.html.
File names may contain the full path, for instance
"D:\PATH\FILE.TXT", or may be in UNC form, e.g.
\\SERVER\SHARE\PATH\FILE.HTM, or device name such as
NULL, CON, LPT1. File name must be enclosed in quotes
if it contains white spaces.
If the Response parameter is omitted, response goes to
standard system output and will be presented on display. In server role
the omitted response is expected on standard input and should be answered
from keyboard.
If both Request and Response are omitted,
all files are redirected to system console. Client writes the
request on keyboard and the received response will be displayed on monitor.
HTTPER server first displays the received request and then prompts
the user to response live from keyboard.
HTTPER utility reports the communication status on screen.
These prompts start with # sign. They don't mix up with
normal HTTPER output because they are directed to standard error output.
HTTPER will set this ERRORLEVEL on exit:
- 0
- Normal exit, data transferred OK.
- 4
- Remote refused communication. It may not listen
on a given TCP port.
- 8
- Remote not found. Network may be down or IP address does not exist.
- 12
- HTTPER timed out.
- 16
- File read or write error, e.g. full disk.
- 20
- Some of the files given on command line was not found.
- 24
- Wrong IP:port address format.
- 28
- Invalid syntax, Help was displayed.
Experimentation with HTTP
Try yourself following exercises if you want to get acquainted with
HTTProtocol and HTTPER utility.
Getting a web page
Let's download a home page from an existing WWW server on intranet or
Internet. Its numeric IP address can be derived from domain addres
using PING domain_address
If some of professional web server such as Apache, Personal Web Server,
MS IIS is running on your computer, you can try the universal
IP address for this computer 127.0.0.1 (localhost). HTTPER.EXE
will be used as a client. When prompted # Enter Request
enter the GET request:
Alternative method is POST. Request-URI specifies only the script
address and parameters are sent in the request body:
Real web servers must answer many requests at the same time.
HTTPER.EXE is a bit stupid - it ignores the content of received
request and always responses with the file specified on command line.
HTTPER terminates itself immediatly once it has answered the first request.
In automatic communication system this can be bypassed with cyclic calling
HTTPER /Server in a batch.