Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Minor problem with 'save destination as' for code.

by blazar (Canon)
on Oct 19, 2008 at 16:48 UTC ( #718069=monkdiscuss: print w/replies, xml ) Need Help??

To put it as briefly as possible, when I save code (to edit, try, etc.) from <code> boxes, I can follow two paths: open in another tab, then 'save as' and 'save destination as' from the contextual menu on the [download] link; the default save name is a conveniently numbered '*.pl' and [download].htm respectively. I understand that the former comes from a header of the form (actual example:)

content-disposition: inline;

I am also aware that the difference in behaviour is at best browser dependent, so

  • the OT part of my question here is: does anybody know of a FF plugin or "hidden" config that will make 'save destination as' look at the headers as well and in case suggest the "correct" filename as a default? (I've searched, but to no avail...)
  • The IT part of it is whether some CSS (e.g. by means of a display: none; property) / JS (to be used by means of the Free Nodelet) / whatever trick may be adopted on the link to similarly suggest the browser the "correct" default filename.
If you can't understand the incipit, then please check the IPB Campaign.

Replies are listed 'Best First'.
Re: Minor problem with 'save destination as' for code. (works)
by tye (Sage) on Oct 19, 2008 at 17:06 UTC

    This already "works for me" in both cases in "both browsers". More specifically, one is FireFox 3.0.3 on Win32 (which exposes "Save Target As" not "Save Destination As" in the context menu). So you may have at least two options: Get a Real™ browser (IE) or Get a Real™ operating system (Win32). ;)

    - tye        

      Firefox 3.0.3 win32, here also. I got "Save Link As", and on first click, it asked to save as Download.htm. Then I opened a new tab, and Ctrl+S prompts to save as If subsequently I try "Save Link As", this time I get Weird I know. Seems to only happen the very first time, so to test, re-start firefox, and first Download Code link will try to save as Download.htm.

        Oops, it is "Save Link As" in FireFox (it is "Save Target As" in IE).

        Seems to only happen the very first time

        It only sometimes happens the first time for each link. It probably happens the first time if PerlMonks takes too long to respond.

        - tye        

      Funnily enough, I am on FF 3.0.3 under Win32!! The "Save Target As" issue is really a matter of my context menu being in Italian and me wanting to write it in a reasonably international way: I thought that the entry would be called "Save Destination As" but it is really "Salva destinazione con nome" for me.

      I cannot exactly confirm Anonymonk's analysis, but indeed the behaviour seems not to be well defined: I tried several times on several different nodes now, and as you say, it works! But I'm sure I have not dreamt of it wanting it to save it to [download].htm yesterday and many other times in the past. Mystery?

      If you can't understand the incipit, then please check the IPB Campaign.
Re: Minor problem with 'save destination as' for code.
by smiffy (Pilgrim) on Oct 19, 2008 at 22:34 UTC


    Please ignore the following, which was my error but I preserve for posterity. I have been assured that this site does not do browser sniffing and I apologise for jumping to conclusions (although it did seem to be the only logical answer) and if my tone may have seemed offensive.

    Original Post (to be ignored)

    If only it were that simple; the problem is deeper-rooted than one might think. I've done a couple of tests which make it look like the code driving this site is engaging in a form of anti-social behaviour called "browser sniffing"

    Try taking the download link and retrieving it with wget or lynx -source or just plain GET if you have it on your system. It gets you a completely different thing to what you would expect based on experiences with a mainstream visual user agent (browser).

    Why do I call browser sniffing antisocial? Because it is poor practice from a web accessibility point of view. Serving different content based on the value of $ENV{HTTP_USER_AGENT} takes control away from the user (never a good thing) and makes what we get unpredictable. Consider a blind person accessing this site using Lynx and EMACSpeak (I know personally at least one person who uses this combo). When they select the 'download' link, they will be presented with something quite unlike what they are expecting. Anyone who wants to see what happens should just open one of these download links in lynx. (For those who can't be bothered, you actually get taken to the Monastery Gates.)

    I am not entirely sure why Perl Monks does this - I'm sure that the motives are honourable. However, browser sniffing a) discriminates against those using different user agents and b) is useless against robots as the first thing that a robot writer does is to make their software pretend to be Firefox, IE or Googlebot. Any of the site ops like to comment on why this is done?

    At the end of the day, I can't say whether browser sniffing is causing your problem or not - it certainly doesn't help trying to trouble-shoot it. I only discovered it by chance, when trying to retrieve the download links using command line tools, in order to try to solve your problem.

      Try taking the download link and retrieving it with wget or lynx -source or just plain GET if you have it on your system. It gets you a completely different thing to what you would expect based on experiences with a mainstream visual user agent (browser).

      I don't know what you get, but i get exactly what i expect, and exactly what i'm getting when sniffing the traffic in firefox (the only exception being the lack of an X-Pad header which has nothing to do with PerlMonks doing any browser detection).

      Perhaps instead of making vague claims that PM is doing bad things and saying "see for yourself" you could be a bit more explicit and say "this is what i see ... and i think it's bad."

        I thought that I had made what I was getting clear but, if it was not, I apologise. (My original post actually states " actually get taken to the Monastery Gates".)

        The test I made was:

        • In Firefox, go to one of the 'Download' links in a node.
        • Right click the link.
        • From the context menu, select 'Copy link location'. (I have verified that what is copied is what shows at the bottom of Firefox when hovering over the link.)
        • Paste the link as an argument for 'lynx'.
        • Lynx loads the 'Monastery Gates' page, NOT the content of the <code></code> block to which the 'Download' link relates.

        The above behaviour is the same if the link is retrieved using wget.

        The main reason that I consider this behaviour bad is that the link target is other than expected (Monastery Gates, not content of <code></code> block.)

      I see that you have duly updated your post: indeed I do hate "browser sniffing" too - there's been a time I have been called "the wgetter" because of my downloading habits. Back then, I stumbled upon a site that wouldn't let me download anything if I were not on either Exploder or Netscape, err... well... or Opera, I presume. Then I discovered how to send an arbitrary additional header; it was only later that the -U cli switch was added. But somehow you got me shocked yesterday! I was about to answer to the point of PerlMonks not behaving at all the way you described. Which in fact is the case! Indeed, the header I pasted in the root node of this thread was the output of a wget -S! Notwithstanding the fact that I have Live http Headers installed... ;)

      If you can't understand the incipit, then please check the IPB Campaign.

        Ooh, cool tool! /me installs livehttpheaders. Thanks for that.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://718069]
Approved by tye
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-01-19 04:31 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (215 votes). Check out past polls.