Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Not getting 401 from xmlhttprequest
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sibil  
View profile  
 More options Nov 5 2009, 6:04 am
From: Sibil <sibilsa...@gmail.com>
Date: Thu, 5 Nov 2009 03:04:26 -0800 (PST)
Local: Thurs, Nov 5 2009 6:04 am
Subject: Not getting 401 from xmlhttprequest
When the server responds with 401, onerror and onreadystatechange
returns r.status as 0. It works fine when the server responds with
200. How can i detect 401?

var r = new XMLHttpRequest();
r.open("POST", "http://api.del.icio.us/v1/posts/update", true); //
expects HTTP-Auth which is not provided.
//r.open("POST", "http://google.com", true); //This works fine.
r.onreadystatechange = function() {
 console.log("hello inside onreadystatechange");
 if (r.readyState == 4) {
  console.log("hello  onreadystatechange:" + r.status);
 }

};

r.onload = function(e) {
 console.log("hello onload");
};

r.onerror = function(e) {
 console.log("hello onerror:" + r.status);
};

console.log("sending test request");
r.send("");

--
Sibil Mohammed


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Boodman  
View profile  
 More options Nov 5 2009, 9:12 pm
From: Aaron Boodman <a...@chromium.org>
Date: Thu, 5 Nov 2009 18:12:48 -0800
Local: Thurs, Nov 5 2009 9:12 pm
Subject: Re: [chromium-extensions] Not getting 401 from xmlhttprequest
Hello Sibil, thanks for reporting this.

I investigated it and I think I see a problem, but it isn't what you describe.

When I try this script from an extension page running in a tab, I get
an auth dialog. If I cancel the dialog, the script does indeed see
that the response status is 401.

If I run the script in a background page, the request just times out.
No response ever comes back.

I can see why this is happening in Chromium. Can you confirm this is
what you're seeing, though?

- a


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sibil  
View profile  
 More options Nov 6 2009, 1:50 am
From: Sibil <sibilsa...@gmail.com>
Date: Thu, 5 Nov 2009 22:50:33 -0800 (PST)
Local: Fri, Nov 6 2009 1:50 am
Subject: Re: Not getting 401 from xmlhttprequest
Thanks for the quick response. I used to see the timeout behavior, i
wanted to report that, strangely it was no longer happening, instead i
get the status as 0.

I just ran the above script from a background page in Chrome version
4.0.223.11, Please find the output below:

sending test request
hello inside onreadystatechange
hello  onreadystatechange:0
hello onerror:0

Luckily now I am getting the timeout behavior as well with an HTTPS
url from the background page.
r.open("POST", "https://api.del.icio.us/v1/posts/update", true); //
Note that it is HTTPS now

--
Sibil Mohammed

On Nov 6, 7:12 am, Aaron Boodman <a...@chromium.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sibil  
View profile  
 More options Nov 12 2009, 4:55 am
From: Sibil <sibilsa...@gmail.com>
Date: Thu, 12 Nov 2009 01:55:09 -0800 (PST)
Local: Thurs, Nov 12 2009 4:55 am
Subject: Re: Not getting 401 from xmlhttprequest
Any updates on this?

--
Sibil Mohammed

On Nov 6, 11:50 am, Sibil <sibilsa...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Boodman  
View profile  
 More options Nov 12 2009, 12:14 pm
From: Aaron Boodman <a...@chromium.org>
Date: Thu, 12 Nov 2009 09:14:45 -0800
Local: Thurs, Nov 12 2009 12:14 pm
Subject: Re: [chromium-extensions] Re: Not getting 401 from xmlhttprequest
No update.

The normal behavior when XHR encounters a site that wants auth is that
it puts up a dialog asking the user for credentials. If we fix this
bug, that is what will happen. Is that what you'd want? Or are you
trying to make it fail?

If you just want it to fail, Could you implement your own timeout
around the call -- say 5 seconds -- as a workaround. If it doesn't
succeed, assume it failed because of auth.

- a


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Boodman  
View profile  
 More options Nov 13 2009, 4:22 am
From: Aaron Boodman <a...@chromium.org>
Date: Fri, 13 Nov 2009 01:22:37 -0800
Local: Fri, Nov 13 2009 4:22 am
Subject: Re: [chromium-extensions] Re: Not getting 401 from xmlhttprequest

On Fri, Nov 13, 2009 at 1:17 AM, Mark Wubben <m...@novemberborn.net> wrote:
> Wouldn't this depend on whether the response contains HTTP Auth headers?
> It'd be very odd if an OAuth request caused a dialog to appear. In  fact,
> especially when handling OAuth requests getting the 401 response is the only
> way of knowing whether the access credentials are invalid.

Hi Mark :)

I was only talking about the case where an auth challenge is served
and the browser would typically present a username/password dialog.
This is the situation I thought TOP was in, because it was all I could
reproduce with the sample code. In this case, when XHR is started from
a Chrome extension view (like a background page or popup), Chrome will
drop the request on the floor and never respond. The bug is that the
extension view doesn't know how to create the auth dialog so it does
nothing there.

Is there also an issue when the auth dialog is *not* expected to occur?

- a


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Wubben  
View profile  
 More options Nov 13 2009, 4:17 am
From: Mark Wubben <m...@novemberborn.net>
Date: Fri, 13 Nov 2009 10:17:39 +0100
Local: Fri, Nov 13 2009 4:17 am
Subject: Re: [chromium-extensions] Re: Not getting 401 from xmlhttprequest
On Nov 12, 2009, at 18:14 , Aaron Boodman wrote:

> The normal behavior when XHR encounters a site that wants auth is that
> it puts up a dialog asking the user for credentials. If we fix this
> bug, that is what will happen. Is that what you'd want? Or are you
> trying to make it fail?

Wouldn't this depend on whether the response contains HTTP Auth  
headers? It'd be very odd if an OAuth request caused a dialog to  
appear. In  fact, especially when handling OAuth requests getting the  
401 response is the only way of knowing whether the access credentials  
are invalid.

--
Mark Wubben

http://supercollider.dk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Wubben  
View profile  
 More options Nov 13 2009, 3:21 pm
From: Mark Wubben <m...@novemberborn.net>
Date: Fri, 13 Nov 2009 21:21:55 +0100
Local: Fri, Nov 13 2009 3:21 pm
Subject: Re: [chromium-extensions] Re: Not getting 401 from xmlhttprequest
On Nov 13, 2009, at 10:22 , Aaron Boodman wrote:

> Hi Mark :)

Hej hej :)

> I was only talking about the case where an auth challenge is served
> and the browser would typically present a username/password dialog.
> This is the situation I thought TOP was in, because it was all I could
> reproduce with the sample code. In this case, when XHR is started from
> a Chrome extension view (like a background page or popup), Chrome will
> drop the request on the floor and never respond. The bug is that the
> extension view doesn't know how to create the auth dialog so it does
> nothing there.

Right, makes sense.

> Is there also an issue when the auth dialog is *not* expected to  
> occur?

Haven't run into it yet, which probably means my OAuth hasn't yet  
broken. Will try it out and see what happens.

Thanks,

--
Mark Wubben

http://supercollider.dk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kris Walker  
View profile  
 More options Nov 16 2009, 12:58 pm
From: Kris Walker <kixxa...@gmail.com>
Date: Mon, 16 Nov 2009 09:58:23 -0800 (PST)
Local: Mon, Nov 16 2009 12:58 pm
Subject: Re: Not getting 401 from xmlhttprequest
Aaron and Mark,

In my case I am using AJAXy XHR on a background page to interact with
a data service that requires authentication and uses the challenge
digest auth scheme per the http authentication spec (http://
tools.ietf.org/html/rfc2617).

The first XHR request is just used to send the username to the server
and get a nonce and nextnonce to hash with the user's passkey, then I
slap a "Authorize" header onto the next XHR request with the hashed
passkey and send it off... So, in other words, I don't want that
dialog popping up.  Mozilla uses XMLHttpRequest.mozBackgroundRequest =
true to make this happen (https://developer.mozilla.org/En/
XMLHttpRequest).

Is there anything in Chromium to make that happen?  Is there a use
defined preference or setting that will do the trick?

-- Kris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Boodman  
View profile  
 More options Nov 16 2009, 2:16 pm
From: Aaron Boodman <a...@google.com>
Date: Mon, 16 Nov 2009 11:16:16 -0800
Local: Mon, Nov 16 2009 2:16 pm
Subject: Re: [chromium-extensions] Re: Not getting 401 from xmlhttprequest

Unfortunately, I don't think that there is anything like that in
WebKit. It does sound useful, though.

- a


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »