Web Perl   «Prev  Next»

Lesson 4Web server basics
ObjectiveHow does a Web server interact with Web browsers?

Web Server Basics

The Web server is a program that runs on an Internet host. There may be many other programs running on that host, including other servers. For the purpose of this course, the term Web server refers to the program itself, not the host computer.

Diagram of a web server
Diagram of a web server

Web Server Interaction

A Web server interacts with a number of Web clients at a time. A client is anything that connects to a server, and in this case, that can be a Web browser (like the one you are using right now), or a robot (such as those used by Alta Vista and Yahoo! to search for and validate Web sites.
This module pays particular attention to the HyperText Transfer Protocol (HTTP). When you view a web page in your browser, it was probably sent to you via HTTP (or HTTPS, the encrypted version of HTTP). HTTP is nothing more than text, and Perl excels at text manipulation. I believe you need a foundation of how HTTP flows between systems to effectively program at a higher level. The first part of this module is about responding as a server. You will create some simple web applications and here are some concepts you need to know. The next part of the module is writing client software: accessing websites, finding links on web pages, using web APIs, and so on.
It is not going to be a full
Here is all you wanted to know about web clients,
but it can get you off to a great web automation beginning.

Brief introduction to HTTP

HTTP is a client-server protocol. That means that a client, such as a web browser or some software you write, makes a request to a server via HTTP and the server responds with a response. It might be a static web page, a page generated on-the-fly, or HTTP responses telling you 404 Page Not Found, the dreaded 500 Server Error, or a 301 Moved Permanently (a redirect). To understand how the web works, you can use a simple telnet client, a standard tool available on all major operating systems (http://en.wikipedia.org/wiki/Telnet). A simple telnet session might look like this:

% telnet example.com 80
Trying 192.0.43.10...
Connected to example.com.
Escape character is '^]'.
HEAD /
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: close
Content-Length: 0
Connection closed by foreign host.

You can use telnet to try to connect to any server on the Internet, but it often fails. Historically, there have been a number of security issues surrounding the telnet protocol and, as a result, many servers disable telnet access. However, you can use telnet and impersonate web, mail, and other clients if you know the rules of the protocol. You can do a bit of that to learn how web clients and servers communicate.

Web Server - Quiz

Click the Quiz link below to answer some short multiple-choice questions about clients and servers. After seeing your results, follow the navigation arrows back to this lesson.
Web Server - Quiz