Troubleshooting a PDF download tool, I was surprised to find out that some mobile browsers behave unexpectedly when trying to directly access a PDF resource through HTTP. While it was pretty obvious that they are lightweight and do not have PDF viewing plugins embedded as their desktop counterparts, even downloading the resource was behaving strangely in some of them.
I tested on my Samsung Galaxy S (GTi9000), a Palm Pre Plus, a Blackberry Torch (9800) and an iPhone 4. All browsers are WebKit based. The test case was pretty simple - download a PDF file from my domain. The PDF was ~200KB in size, to keep the tests quick.
To debug the actual HTTP traffic of the devices, I interposed Fiddler as a reverse proxy between my domain and them. This way, I was able to log all the headers and content of all the HTTP requests and responses made.
Let’s start with the responses, the server was not configured in any way to serve PDFs, so it gave the same response regardless of the request headers it received.
The caching headers are automatically inserted by the server, but they did not seem to affect the devices since the content was being downloaded for every request.
Now for the interesting part: besides the iPhone browser, all others make two requests for the file, which means the content is downloaded twice!
The BlackBerry first sends a complete request and then repeats it identically:
User-Agent:Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-GB) AppleWebKit/534.1+(KHTML,likeGecko)Version/184.108.40.206 Mobile Safari/534.1+