We need to return the URL as a header in AJAX request for logging

Bug #745486 reported by Huw Wilkins
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
High
Unassigned

Bug Description

As part of an AJAX log of times we would like to include the URL. It seems the only way to get this URL is to return it as a x-header.

Can we add a new header? Something like: X-LP-URL

I think we should return this on all AJAX requests. Lifeless helpfully adds: "api requests on non api domains are ajax requests" if that helps in determining when to add this header.

Tags: easy
Revision history for this message
Deryck Hodge (deryck) wrote :

Independent of the request for a new header here, I'm confused a bit. You want to log AJAX requests but don't know the URL being requested? How can you make a XHR without a URL?

Perhaps you could explain more about what you're trying to do and what you don't have access to the URL, just in case there's some way to get the URL that isn't obvious. My apologies if you've been over this with others and already covered this ground.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 745486] Re: We need to return the URL as a header in AJAX request for logging

On Thu, Mar 31, 2011 at 6:47 AM, Deryck Hodge
<email address hidden> wrote:
> Independent of the request for a new header here, I'm confused a bit.
> You want to log AJAX requests but don't know the URL being requested?
> How can you make a XHR without a URL?
>
> Perhaps you could explain more about what you're trying to do and what
> you don't have access to the URL, just in case there's some way to get
> the URL that isn't obvious.  My apologies if you've been over this with
> others and already covered this ground.

the response object doesn't know the originating url in a
cross-browser fashion; the log hooks into the response handler not the
submission.

Revision history for this message
Huw Wilkins (huwshimi) wrote :

@Deryck

We're using on:start/io:complete which attaches to all AJAX events. The data available to those events is limited to the response and headers. You can see this here: http://developer.yahoo.com/yui/3/io/#events

The x-header looks like the simplest way to get the URL without modifying every AJAX request.

Changed in launchpad:
importance: Low → High
assignee: nobody → William Grant (wgrant)
Revision history for this message
Deryck Hodge (deryck) wrote :

Thanks, Huw and Robert, for the explanations. I had a poke at the code yesterday myself just because my expectation would have been the Y.io would have provided this for you. It's odd, to me, that it doesn't. While I think the header idea is fine and useful beyond this particular use, I may have a play this weekend at adding the request URL to all the Y.io event hooks. Seems generally useful. We'll see if YUI takes it upstream, and if they are warm to the idea, we can merge that into our YUI.

Also, I noticed the arguments array was being overwritten in one of the callbacks, so I did a quick branch to fix this up. https://code.launchpad.net/~deryck/launchpad/xhr-log-not-overwrite-arguments/+merge/55750

Thanks for this work, Huw. It's going to be quite useful when generally available.

Cheers,
deryck

Revision history for this message
Huw Wilkins (huwshimi) wrote :

Thanks Deryck, I didn't realise that was happening.

William Grant (wgrant)
Changed in launchpad:
assignee: William Grant (wgrant) → nobody
tags: added: easy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.