Introduction
Web Clients and ServersSubstitutions:
Topics of DiscussionWhat is a Protocol?At the post office:
The customer and the server communicate via protocols. Protocols mediate the interaction, ie they make it work. What is a Web Client?
A real, live, Web Client#!/usr/bin/perl use LWP::Simple; print get 'http://savage.net.au/index.html'; This 3 line program is a complete, tested, web client A real, live, SOAP Server #!/usr/bin/perl
# Name: server-1.cgi.
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI -> dispatch_to('Demo') -> handle;
package Demo;
sub hi{return "Hello, world";}
This 6 line program is a complete, tested, SOAP server A real, live, SOAP Client #!/usr/bin/perl
# Name: server-1-client-1.pl.
use SOAP::Lite;
print SOAP::Lite -> proxy('http://127.0.0.1/cgi-bin/soap/server-1.cgi') -> uri('Demo') -> hi() -> result;
This 4 line program is a complete, tested, SOAP client Output from that SOAP ClientDOS>perl server-1-client-1.pl Hello, world That's all, folks! OK, so there was no error checking. Next time! Running a Script<img src = 'web-servers-slide-10.png'> The Request Loop<img src = 'web-servers-slide-11.png'> Finding the Destination
Special Destinations
127.0.0.1
DNS under MS Windows
The hosts file# A hash starts a comment 127.0.0.1 ronnie.net.au 127.0.0.1 iris.ron.net.au 127.0.0.2 violet.net.au http://ronnie.net.au/index.html is the same as http://127.0.0.1/index.html Encoding the Message
Finding the Server
What is port 80?
Other Ports
Load Balancing
Decoding the Message
Processing the Message
Processing a URI
/ is a directory
A CGI script #!/usr/bin/perl
use CGI;
my($q) = CGI -> new();
print $q -> header(),
$q -> start_html(),
$q -> start_form({action => $q -> url(), name => 'a_form'}),
'Email address: ',
$q -> textfield({name => 'email', size => 40}),
$q -> submit(),
$q -> end_form(),
$q -> end_html();
This 4 line program is a complete, tested, CGI script. Output from a CGI ScriptAnd this is the output from that CGI script, slightly simplified. <html><head>�</head><body> <form action = 'http://127.0.0.1/cgi-bin/script.cgi', name = 'a_form'> Email address: <input type='text' name='email' size='40' /> <input type='submit'> </form></body></html> Why output that form?
Interpretation
When the CGI script gets data
Resources
AuthorRon Savage Home page: http://savage.net.au/index.html
LicenceAustralian Copyright © 2002 Ron Savage. All rights reserved. All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Artistic License, a copy of which is available at: http://www.opensource.org/licenses/index.html |
| Top of page |