From a570a39f2e2234de74c0032fde002695049b9f08 Mon Sep 17 00:00:00 2001 From: "battre@chromium.org" Date: Wed, 18 Jan 2012 15:28:08 +0000 Subject: Fix example of onBeforeSendHeaders in webRequest API documentation BUG=110359 TEST=no Review URL: https://chromiumcodereview.appspot.com/9215008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118094 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/extensions/docs/static/webRequest.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'chrome/common/extensions/docs/static') diff --git a/chrome/common/extensions/docs/static/webRequest.html b/chrome/common/extensions/docs/static/webRequest.html index 33c61c7..a0c1342 100644 --- a/chrome/common/extensions/docs/static/webRequest.html +++ b/chrome/common/extensions/docs/static/webRequest.html @@ -281,11 +281,16 @@ all requests:

 chrome.webRequest.onBeforeSendHeaders.addListener(
   function(details) {
-    delete details.requestHeaders['User-Agent'];
+    for (var i = 0; i < details.requestHeaders.length; ++i) {
+      if (details.requestHeaders[i].name === 'User-Agent') {
+        details.requestHeaders.splice(i, 1);
+        break;
+      }
+    }
     return {requestHeaders: details.requestHeaders};
   },
   {urls: ["<all_urls>"]},
-  ["blocking"]);
+  ["blocking", "requestHeaders"]);
 

For more example code, see the web request -- cgit v1.1