Programming a web server, you have to know a little bit about what to expect for incoming packets, and what to send back. My little web server is working, and thought to test with my iPod.
The text was freaking small, unreadable without magnification. There has to be a simpler way. Fortunately, there is, and it is quite simple to detect mobile phones and send back the appropriate DOCTYPE.
When the iPod sends a request for page, this is what is received:
GET / HTTP/1.1
Host: xxx.xxx.xxx.xxx
User-Agent: Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
I can parse out "Mobile" as well as "iPod, iPhone, etc.. to flag mobile device.
on the outgoing message, I select the appropriate DOCTYPE! for the MobileFlag:
HTTP/1.1 200 OK
Date: Tue, Nov 23, 2010 9:37:33 AM
Server: PAFserver3
Content-Type: text/html
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html>
<head>
...
The text on the Safari browser on the iPod is easily readable.
Soon, I will open this server to the internet for testing, using an obscure port number. Those who are interested on this project, let me know. I would like to sample other mobile devices to make sure I have a good capture code on what is Mobile, and what isn't.