otsukare Thoughts after a day of work

I like it hardcoded, but not in my code (SFW)

This is a simple reminder to the Web Developer Community. Hardcoded strings are bad, even for a quick hack to solve an issue that you will forget the day after tomorrow. One of the most recent examples is a site which after being contacted has modified its user agent detection code so Firefox OS would receive the mobile content instead of the desktop content.

So this is what you get when you access the Web site with Firefox OS 1.0. The browser is redirected to http://mobile.lepoint.fr/

Request:

GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: www.lepoint.fr
User-Agent: Mozilla/5.0 (Mobile; rv:18.0) Gecko/18.0 Firefox/18.0

Response:

HTTP/1.1 301 Moved Permanently
Content-Encoding: gzip
Content-Length: 40987
Content-Type: text/html
Date: Wed, 27 Nov 2013 16:47:53 GMT
Location: http://mobile.lepoint.fr/
Server: Apache/2.2.25 (Unix) PHP/5.2.17
Vary: User-Agent,Accept-Encoding
X-Powered-By: PHP/5.2.17

And this is what you get when you access the Web site with Firefox 1.1. The browser gets the desktop version of the content.

Request:

GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Host: www.lepoint.fr
User-Agent: Mozilla/5.0 (Mobile; rv:18.1) Gecko/18.1 Firefox/18.1

Response:

HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length: 40642
Content-Type: text/html
Date: Wed, 27 Nov 2013 16:48:58 GMT
Server: Apache/2.2.25 (Unix) PHP/5.2.17
Vary: User-Agent,Accept-Encoding
X-Powered-By: PHP/5.2.17

So those with an eagle eye will notice that the only difference in between those two is the version number from 18.0 to 18.1. As a matter of fact you can try any number different from 18.0 and you will get the desktop version.

What could you do?

  1. identify s/mobi/i
  2. remove ipad from the lot

In that way you will maximize the effect by allowing our friends like Opera Mobile, etc. and you will avoid the iPad Tablets that have a Mobile string.

Otsukare!