O'Reilly logo

PHP Web Services by Lorna Jane Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. HTTP

HTTP stands for HyperText Transfer Protocol, and is the basis upon which the web is built. Each HTTP transaction consists of a request and a response. The HTTP protocol itself is made up of many pieces; there’s the URL that the request was directed at, the verb that was used, other headers and status codes - and of course the body of the responses which is what we usually see when we browse the web in a browser.

As an example, point a browser at http://oreilly.com/ and see a page looking something like Figure 2-1; we either find the information on the page or we use the hyperlinks on that page to journey onwards for the information desired.

O’Reilly Homepage
Figure 2-1. O’Reilly Homepage

The web page arrives in the body of the HTTP response, but it tells only half of the story. The rest is in the other parts of the HTTP request and response and for this example, we see something like this:

Request header:

GET / HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1246.0 Safari/537.8
Host: oreilly.com
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6

Response header:

HTTP/1.1 200 OK Date: Thu, 15 Nov 2012 09:36:05 GMT Server: Apache Last-Modified: Thu, 15 Nov 2012 08:35:04 GMT Accept-Ranges: bytes Content-Length: 80554 Content-Type: text/html; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required