Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:36:18+00:00 2026-06-17T10:36:18+00:00

I am creating an extension targeted at a specific site whose servers I do

  • 0

I am creating an extension targeted at a specific site whose servers I do not have access to. I am attempting to handle HTTP 302 redirects in a way that lets me use a HEAD request to get the redirect url. My code for doing so is this:

var redirUrl = "";
var requestId = 0;

chrome.webRequest.onBeforeRedirect.addListener(function(details){
  console.log("before redirect");
  if(details.method == "HEAD"){
    redirUrl = details.redirectUrl;
    requestId = details.requestId;
  }
},
{urls: [matchUrl]});

chrome.webRequest.onHeadersReceived.addListener(function(details){
  console.log("on headers received");
  if(details.requestId == requestId){
    var temp = {"name":"redirUrl","value":redirUrl};
    details.responseHeaders.push(temp);    
  }  
  return {responseHeaders:details.responseHeaders};  
},
{urls: [matchUrl]},["responseHeaders", "blocking"]);

chrome.webRequest.onCompleted.addListener(function(details){
  console.log(JSON.stringify(details.responseHeaders));
},
{urls: [matchUrl]},["responseHeaders"]);

Now currently the matching is non specific enough to trigger these events with normal navigation to a matched url. Upon doing so things proceed perfectly fine, of course not being a HEAD request it does not add anything. Even if I allow all redirected requests, the header is added just fine. My problem arises when I try to call this in a different place in my background js file:

 $.ajax({
   url: url,
   data: datas,
   type: "HEAD",
   success: function(data,statusCode, jqXHR){
     console.log(jqXHR.getAllResponseHeaders());
   }      
 }); 

The blocking part of the onHeadersRecieved listener prevents the event from being fired at all, and if I remove the blocking there is not enough time to append the header. So my question would be what could be preventing it from firing the event properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:36:20+00:00Added an answer on June 17, 2026 at 10:36 am

    Well it seems that this is a bug in chrome and not in my code and the fix should work its way down to the stable channel at some point, hopefully sooner rather than later. I believe it may be this issue, or at least related to it, and this code is confirmed to work in 26.0.1386.0 canary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have starting creating my first firefox extension. I am following http://extensions.roachfiend.com/howto_bug.html But seems
I'm creating a Visual Studio 2010 extension using a Package template, not an Add-in.
I am working on creating a Google Chrome extension. We have it included in
I'm creating a Firefox extension and I have a folder with files of the
I'm creating a chrome extension which uses http://loopj.com/jquery-tokeninput/ to add tokens, see previous question
I have problems creating a ruby extension to export a C++ library I wrote
Hey I have tried a lot creating spree extension , but after weeks efforts
I'm creating a Firefox extension for demo purposes. I to call a specific JavaScript
I am creating an extension for Chrome. I want to show an alert() with
I'm creating a chrome extension, and want to be able to get a profile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.