HttpListener Series – 0 – What is HTTP?   2 comments

The series index here.

When I started working in computer programming (not that long ago) I was amazed how developers (not necessarily bad ones) didn’t know, or care to know, about what happens underneath their coding and what standards rule their unconscious processes. As 90% of the computer programming work I see and do is web-base, I find it intriguing, to say the least, the amount of “professionals” that don’t know what HTTP and a HTTP request/repsonse is. I’ll try and make it simple.

This is one of the rare cases where a naming in technology (computer, mainly) didn’t loose it’s meaning with its extended usage.

H.T.T.P. stands for Hypertext Transfer Protocol.

So, it’s a protocol (a set of rules and standards) to communicate data that is not just text. It’s official documentation is set and provided by W3C (World Wide Web Consortium) here.

I won’t go into the deep depths of the bits communication but, you can go there by looking into Sockets or, up one level, TCP. Let’s just say that, for a HTTP communication to occur, a Socket connection based on TCP must be open.

HTTP provides a standardization for a request-response data in a client-server communication. A raw HTTP request and consequent response look like so…

The request:

GET http://localhost/HLD/ HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: localhost
Pragma: no-cache

The response:

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-HTTPAPI/2.0
Date: Wed, 04 Jul 2012 15:04:59 GMT

<!DOCTYPE HTML><html><head><title>Http Listener demo.</title></head><body>Hello, this is the HttpListener responding.</body></html>

Simple, no? A first line defining:

– in the request: the type “GET” (or method, we’ll get there); the resource to retrieve “http://localhost/HLD/”; and the protocol version “HTTP/1.1”

– in the response; the procotol version “HTTP/1.1”; the repsonse status code “200”; and the status description “OK”.

A bunch of, so called, headers. “New line” separated values in the form of name:value.

And, in this case just in the response, some content which, in this case, happens to be HTML.

In the end, the protocol provides a way a of, in a commonly known manner,  communicate data with some extra information that helps each side deal with the data in an organize and predictable way.

There really isn’t much more to say about the protocol but it is, IMO, vital to know this happens to understand what goes on underneath every client (e.g., a web-browser) request. Of course, the protocol provides, though methods, headers and statuses ton’s of standardized functionalities. I’ll go through some of those along these series.

See ya!


Posted 2012/07/04 by Bigsby in Hands On

Tagged with ,

2 responses to “HttpListener Series – 0 – What is HTTP?

Subscribe to comments with RSS.

  1. Pingback: HttpListener Series « Bigsby Spot

  2. Pingback: HttpListener Series – 1 – Get It Listening « Bigsby Spot

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: