views:

142

answers:

1

Hy people. I'm working on my webapp for the iphone. On some point you have the option to get a particular document from our appserver. It works on firefox, but safari just shows an empty download window. IE also can't get the file.

Below is the example link.

Is there something wrong with a link of this kind that Safari can't see?

http://192.168.200.32:9999/USER_STORAGE?user=bt&token=bEVfjg%2FGHoHHU2CxmAWyiTXFUgN9kN2o8pEKgCFV5Fw%3D&nonce=9jJgj4qGXB4U7m%2FJXjjsmbfreH2J2nT8D789jHY6zro%3D&parent_session=cjDEN3PvltsAqjiagynS8mN6HKeAgqWv82WJqxWiXD8%3D&method=download&filename=Testdokument2

+2  A: 

The W3 validator points out that you need to escape those ampersands. We mostly get away not escaping them, but who knows, maybe that's the issue. So:

http://192.168.200.32:9999/USER_STORAGE?user=bt&token=bEVfjg%2FGHoHHU2CxmAWyiTXFUgN9kN2o8pEKgCFV5Fw%3D&nonce=9jJgj4qGXB4U7m%2FJXjjsmbfreH2J2nT8D789jHY6zro%3D&parent_session=cjDEN3PvltsAqjiagynS8mN6HKeAgqWv82WJqxWiXD8%3D&method=download&filename=Testdokument2

..although I tested those params unescaped and they worked fine on IE7, IE8, Chrome4, Safari4, and Firefox3.6 on Windows. (See test page below)

If that's not it:

  • Are you testing it by navigating to that point in the desired browser, rather than copy-and-paste? (E.g., does the session mechanism rely on a cookie, or disregard attempts from a different user agent, or...?)
  • If there are cookies involved, does this link use a different port from the response that set the cookie?

My unescaped test page, worked as expected despite being invalid:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Test Page</title>
<style type='text/css'>
body {
    font-family: sans-serif;
}
</style>
</head>
<body><div>
<a href='showparams.jsp?user=bt&token=bEVfjg%2FGHoHHU2CxmAWyiTXFUgN9kN2o8pEKgCFV5Fw%3D&nonce=9jJgj4qGXB4U7m%2FJXjjsmbfreH2J2nT8D789jHY6zro%3D&parent_session=cjDEN3PvltsAqjiagynS8mN6HKeAgqWv82WJqxWiXD8%3D&method=download&filename=Testdokument2' target='_blank'>the link</a>
</div></body>
</html>

Escaped test page, also worked as expected:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Test Page</title>
<style type='text/css'>
body {
   font-family: sans-serif;
}
</style>
</head>
<body><div>
<a href='showparams.jsp?user=bt&amp;token=bEVfjg%2FGHoHHU2CxmAWyiTXFUgN9kN2o8pEKgCFV5Fw%3D&amp;nonce=9jJgj4qGXB4U7m%2FJXjjsmbfreH2J2nT8D789jHY6zro%3D&amp;parent_session=cjDEN3PvltsAqjiagynS8mN6HKeAgqWv82WJqxWiXD8%3D&amp;method=download&amp;filename=Testdokument2' target='_blank'>the link</a>
</div></body>
</html>
T.J. Crowder
done it both. First using safari, authenticating (creating session), then browsing to the documents menu, parsing the documents correct, and then getting the URL for a particular document using a GET request with the ID of the document (very simple).
Johua
Johua
@Johua: It sounds to me like the *link* is fine, then, and as Victor Jalencas suggested the problem lies not in the link but in the request or response. If it's of any help, the `Content-Disposition` response header I've used successfully with all of the browsers above to trigger a download dialog (rather than opening in a window) is `attachment; filename=foo.pdf` (or whatever the filename is). Similarly, when suggesting opening the document in the browser window instead, `inline; filename=foo.pdf` has worked for me.
T.J. Crowder
Johua
thx Crowder..i'm in a hurry now to test will post back ASAP
Johua
Hy i'm back to response. Well :( it didn't work. Here is wat i got:The url now opens a dialog box asking you to open OR save the file (pdf,word,..etc). But when i actually want to save OR view the file i get a "connection was lost" ERROR. This happens for all browsers. Strange, but when i copy the URL directly from my XML file -> it works. So I think, that something happens from XML to WebBrowser.
Johua
@Johua: It sounds like a problem on the server side to me, FWIW.
T.J. Crowder
@ T.J. Crowder: THX! Is there a button or something to rate you for the help? Cause i'm relative new here and don't see anything pointing to a "this answers the question"...
Johua
@Johua: Glad that helped. When you see good questions or good answers (even to other peoples' questions), you can click the up arrow next to it to vote it up. That awards some reputation to the person who posted it. Separately, on your own questions, if one of the answers is the right answer, you can click the checkmark next to it, which means you've "accepted" the answer. That also awards some rep to the person who answered. More here: http://stackoverflow.com/faq
T.J. Crowder
Hy i'm very blind for finding those things,..i'm looking and looking but don't see any checkmark next to your awnsers,...i'll check it up in the morning (gmt+1).
Johua
@Johua: At the very top of my answer, to the left, there's an up-arrow, a number ("1" as I write this, it may change), and a down-arrow. Underneath the down-arrow is a check mark. That's what you click.
T.J. Crowder
checked. voteup requires 15 reputation..so that i could not. Anyway..see ya :)
Johua
@Johua: Doh! Hadn't thought of that. :-)
T.J. Crowder