Receive debugging information alongside XMLHttpRequests.
DebugR Extension
Server code (example is php, but the extension is language agnostic):
if (isset($_SERVER['HTTP_DEBUGR'])) { // Only send headers when DebugR is enabled
// Send a message alongside the request.
header('DebugR: '.base64_encode('Hello DebugR'));
// Append a unique label to send multiple messages.
header('DebugR-my-first-label: '.base64_encode('Moarr information'));
}
?>
Client via javascript:
window.addEventListener('message', function (e) {
if (e.data.debugR) {
console.log(e.data);
}
}, false);
document.documentElement.setAttribute('data-debugR'); // Signal the extension that the eventlistener is active.
Using debugr.js helper:
Read more
if (isset($_SERVER['HTTP_DEBUGR'])) { // Only send headers when DebugR is enabled
// Send a message alongside the request.
header('DebugR: '.base64_encode('Hello DebugR'));
// Append a unique label to send multiple messages.
header('DebugR-my-first-label: '.base64_encode('Moarr information'));
}
?>
Client via javascript:
window.addEventListener('message', function (e) {
if (e.data.debugR) {
console.log(e.data);
}
}, false);
document.documentElement.setAttribute('data-debugR'); // Signal the extension that the eventlistener is active.
Using debugr.js helper:
Source Manifest.json
{"update_url": "https://clients2.google.com/service/update2/crx",\t"name": "DebugR",\t"version": "1.3",\t"manifest_version": 2,\t"description": "Receive debugging information alongside XMLHttpRequests.",\t"icons": {\t\t"16": "img/16.png",\t\t"128": "img/128.png"\t},\t"background": {\t\t"scripts": ["js/debugr-Daemon.js"]\t},\t"content_scripts": [{\t\t"matches": ["http://*/*", "https://*/*"],\t\t"js": ["js/debugr-forwarder.js"],\t\t"run_at": "document_start"\t}],\t"permissions": [\t\t"webRequest",\t\t"webRequestBlocking",\t\t"tabs",\t\t"http://*/*",\t\t"https://*/*"\t]}
Read more