Archive for the ‘self-hosted webserver’ Tag

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 ,

HttpListener Series   Leave a comment

In this series, all about HttpListener class will thoroughly explained and exemplified. After this, any one will be able to self-host web-based scenarios without the need of an IIS and everything that comes with it.

The series is divided in the following topics (links will be provided along completion of each topic):

0 – What is HTTP? – Overview of HT.T. Protocol

1 – Get it listening

2 – Websiting – Simple web site hosting

3 – Windows Authentication – Using Windows provided authentication

4 – "Manual" Authentication – Handling HTTP authentication

5 – ASPing – Non-static request processing

6 – HTTPS – SSL secure communication

7 – WCF Data Service Hosting – OData is friends with HttpListener


As always, if there is any suggestion or unanswered topic about the subject, feel free to comment anywhere. I’ll be delighted to make this series as though and helpful as I can.

A full working solution with all these implementations can be downloaded here:

Posted 2012/07/04 by Bigsby in Hands On

Tagged with , ,