[main] [misc] [graphics] [page design] [site design] [xhtml] [css] [xml] [xsl] [schema] [javascript] [php] [mysql]

HVCC Home
Blackboard HVCC
Blackboard Manual
Faculty Association

php main
1. what is php
* 2. http basics
3. php basics
4. php expressions
5. php client side
6. php flow control
7. php manual


print version

Note that all external links will open up in a separate window.

This is a stripped down version of these pages for older browsers. These pages are really meant to be viewed in a standards compliant browser.

Directions for surfing with audio.

HTTP Basics

These tutorials are about general networking protocols on the Internet.

HTTP Basics

HTTP: the HyperText Transfer Protocol is the transmission protocol used to transmit Web pages on the Internet

HTTP, or Hypertext Transfer Protocol is the network protocol used to transmit Web content over the Internet. It works with TCP/IP to transmit information. IP stands for Internet Protocol and handles packaging information for delivery. TCP is the Transmission Control Protocol and it handles packaging information for delivery. HTTP handles addressing the package and providing information that allows the client and server to effectively communicate over the Web.

Yes that's way too many acronyms.

Anyway, any online application has numerous layers that it is working in or through. Each layer handles a specific aspect of the task at hand. For instance, when you open a Web browser, you have your operating system, your user account and preferences, the application, and the actual display of the page you are viewing all working together on the screen. On the Internet you have separate layers handling the transmission of data, the packaging of data, and the addressing of data.

One way to grasp it is to imagine you work for a large wholesale company that delivers its own goods. The Transmission Control Protocol is like the delivery fleet that ships the goods. The Internet Protocol is the shipping room at the front of the warehouse, where things are pulled out of the warehouse (the server) and packaged for delivery to the client. Hypertext Transfer Protocol is the sales department that writes up the invoices and, more importantly, the shipping labels for the packers and drivers to use to figure out what to pack and where it goes.

Most of what we talk about when we talk about HTTP is the information it adds to the data package being shipped in order to increase the efficiency of delivery and the usability of the information on both sides of the transaction.

In its simplest form, we can think of HTTP as nothing more than a header, or shipping label, and the protocols for processing the data in this header. If you have ever sent a package by UPS, then you know there is more to a shipping label than just the address it is being sent to. The HTTP header is a protocol that tries to pass all the information an application on the client or server may need from the other end of the transaction.

An HTTP message can be broken into three parts.

  • the request/response line
  • the HTTP header
  • the body of the message

The body of the message is either the content being sent from the server to the client, or form data or an uploaded file being sent from the client to the server. In other words, it is the thing we think of as being the document we sent or received. Not much more needs to be said about that here. However, the other two sections can use some explanation.

Request and Response

If the request line can be seen as a specification of what to order from whom, the response line can be seen as the receipt confirming that the transaction took place. There can only be one of the two in any message.

URI: the Uniform Resource Indicator, a superset of the URL, is a protocol for uniquely identifying every document accessible on the Internet

The request contains three critical pieces of information. The first is the method of request, which is to say, how the server is supposed to process it. The second is the path to the resource being requested. The third is the version number of HTTP being used.

The method tells the server how to handle the request. The three most common are GET, HEAD, and POST.

GET
This is a simple request for a document or resource residing at a specific URI (Uniform Resource Indicator). It is the most common type of Web request.
HEAD
This is similar to a GET request, except that it is only looking for HTTP header information on the resource, not the resource itself.
POST
Indicates that information is being sent the the server inside the HTTP body. The URI should point to a resource capable of handling the data being posted.

A typical request header might look something like this:

GET /index.php HTTP/1.1

The reply line indicates whether the request was successful. It includes the protocol being used, a numeric status code, and a short description of the status code.

HTTP/1.1 200 OK

The numeric status codes fall into the following ranges:

100-199
Information messages on the current status of processing.
200-299
Successful request.
300-399
Request cancelled because document or resource has been moved.
400-499
Client error. The request was incomplete, incorrect, or otherwise unresolvable.
500-599
Server error. Request appears valid, but server could not complete it.

The most common status message people get to see is 404 Not Found, which simply means that document you requested does not exists. This is either because it really doesn't exist or because you entered the URL wrong. When a 404 is returned it is usually displayed on the browser screen in whatever default format is used by that browser. The server may also transmit a detailed error report page along with an error message if the resource call was unsuccessful.

The HTTP Header

People who know just enough HTML to be dangerous encounter the term HTTP header and may think that is corresponds in some way to the document header in an HTML document. This is not the case. The HTML document header is something you have coded into the document between <head> tags, and, as far as the server is concerned, is part of the document content being sent. The HTML header is information the author has provided for the client application about the document. The HTTP header, on the other hand, is information the client and server provide each other about the transmission process for the document.

If you need a concrete example, think of the HTML header as the date and address written at the top of a business letter, while the HTTP header is the address written on the outside of the envelope. They may both be addresses, but they are physically different things in physically different locations.

The HTTP header contains details about the transaction between the client and server, with slight variations depending on whether it is a request or a response. The header information can be grouped into three different categories. These are:

General
General information fields contain information about either the client or the server. General information can be as general as nothing but the current date and time.
Entity
Entity information fields contain information about the data being transmitted. Common entity information is the date on which the document or resource was last modified or the address of the document requesting this one.
Request/Response
The request/response fields contain information about the client and server configuration, including what sort of documents the client can accept and what sort of requests the server can accept. This information includes the server name and version for the server, and the client application name and version for the client. It also includes the platform being used by the client or the server. This information is often used by client or server applications to customize the request or response for the needs of the application on the other end of the connection. It can also be used to specify what sort of documents the client can recieve, so, for example, the server knows not to try to send images or audio files to a text-only interface.

Each header field is delimited by a line break at the end. In other words, each data field is written on its own line. The end of the header section is delimited by one or more blank lines. In computer terms, a blank line is nothing but some form of newline character. So the end of the header section is actually delimited by a sequence of line break characters with nothing between them.

A sample request header might look as follows:

GET /tutorials/utils/servervars.php HTTP/1.1
Accept: text/html, image/png, image/jpeg, image/gif, */*
Accept-Language: en
Accept-Encoding: deflate, gzip, x-gzip, identity, *
Connection: Keep-Alive
Host: localhost
Referer: http://localhost/tutorials/utils/
User-Agent: Opera/6.05 (Windows XP; U) [en]

A sample response header might look as follows:

HTTP/1.1 200 OK
Date: Wed, 22nd Jan 2003 11:15:15 GMT
Server: Apache/2.0.43 (Win32) PHP/4.3.0
Last-modified: Wed, 22nd Jan 2003 11:10:47 GMT

[top]