Wednesday, May 9, 2007

Serving to the web

Last night I finished to write the UmitWeb's web server. I worked hard, and it's working fine now. I would like to introduce you some features included in this 'bundled' server:
  • Elegant URL Mapping
  • GET and POST parameters
  • File upload
  • Cookies
  • Session

Elegant URL Mapping

I am a django developer, and I like so much the way that it handles the URL passed by the user. In an url config module, we type some url patterns (using regular expressions), and assign each pattern with a function, that must returns a HttpResponse. I did a work likes this, handling URLs by matching them with regular expressions, associated with functions that are called, each at their time.

GET and POST parameters

This is basic functions that are essential for a web browser. GET (via URL) and POST (via request body) methods are handled in a class called HttpRequest, that encapsulate these attributes in a 'pythonic way' (stored on dictionaries).

File Upload

UmitWeb must be able to manage uploaded files (like options, profiles and result scans), so its web server must work with file upload. This feature is working by handling multipart/form-data requests content-types, that works different from the default POST request (x-www-urlencoded). This took a more longer time, and a specia attention, but all about it is working fine now.

Cookies

Another important feature. Cookies can store variables in the client web browser. It is good, but it is bad too. Cookies can make your application insecure, and can be a security hole, but it is so useful (and also essential) when we work with sessions.

Session

Sessions are NOT a HTTP standard, but it has been used by several web servers to store data in a secure way: A cookie is sent to the web browser, with the value of you session's ID. This session ID is associated, in the server, with a dictionary that store data about that session. This dictionary is serialized and stored in a SQLite database. When the users closes the browser, or when he finishes the sessions, all information is destroyed.


Ok, that's all for a while. I shall write more posts about the UmitWeb project soon.

No comments: