As presented at ZendCon, Confoo, LaraconEU, ZgPHP, PFCongres and Fronteers User Group. An overview of some intermediate level HTTP features and how they might be useful in practice.
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
2 Parts
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
The body
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>My application</title>
...
The body
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
The body
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
The headers
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
The good stuf
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
GET, POST, PUT, DELETE
Request Relative URL
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
HTTP version
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
Key/Value pairs
Request
POST /gists HTTP/1.1
Authorization: Basic xxxxxxxx
Host: api.github.com
Content-Length: 146
{
"description": "the description for this gist",
"public": false,
"files": {
...
Response
HTTP/1.1 201 Created
Date: Sun, 09 Sep 2012 11:42:41 GMT
Content-Length: 1848
Location: https://api.github.com/gists/a43a0cf58
{
"description": "the description for this gist",
"comments": 0,
"created_at": "2012-09-09T11:42:40Z",
...
Status code
• 2xx
• 3xx
• 4xx
• 5xx
OK!
Over there!
Client screwed up!
Server screwed up!