Problem:
Currently, when caching is enabled, the cached file, downloaded from Baidu Analytics' server through the URL http://hm.baidu.com/h.js (Standard code) or http://hm.baidu.com/hm.js (Asynchronous code), to the site's files directory, seems to actually download and save an empty file.
This is most likely due to the fact that with a direct access to Baidu Analytics' JS tracking file URL, for example:
http://hm.baidu.com/h.js?0123456789abcdef0123456789abcdef
a 200 code is returned (OK), but the output is empty.
The issue could probably come from the headers and Baidu Analytics' servers would only allow the tracked domain name to receive full output of the JavaScript tracking code. The problem could perhaps be resolved by overridding the HTTP headers and providing the $base_url as the referer.
Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of this bug report, I would be glad to provide more information or explain in more details.
Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.
Comments
Comment #1
dydave commentedQuick follow-up on this bug report:
Modified the call to
drupal_http_requestin the caching function_baidu_analytics_cacheto provide current site's URL$base_urlin HTTP request's headerreferer, as suggested in the issue summary.Added a short inline comment in code to explain why this override is necessary:
I went ahead and committed the changes against the 7.x-1.x branch at 6565270.
I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with this ticket or related commit 6565270 (we would surely be happy to hear your feedback).
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commit or this bug report in general, I would be glad to provide more information or explain in more details.
Special thanks to @xiukun.zhou for investigating the problem, debugging and coming up with a very nice/clean solution.
Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!